package com.ss.android.article.base.feature.detail2.video;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.content.Intent;
import android.content.SharedPreferences;
import android.content.res.Resources;
import android.graphics.ColorFilter;
import android.graphics.Paint;
import android.graphics.drawable.Drawable;
import android.net.Uri;
import android.os.Build;
import android.os.Bundle;
import android.os.Message;
import android.os.Parcelable;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentActivity;
import android.support.v4.content.ContextCompat;
import android.text.TextUtils;
import android.util.Log;
import android.util.Pair;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ViewParent;
import android.view.ViewTreeObserver;
import android.view.animation.Animation;
import android.view.animation.TranslateAnimation;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.bytedance.article.common.a.MonitorFPS;
import com.bytedance.article.common.c.JSONObjectWrapper;
import com.bytedance.article.common.c.TTUtils;
import com.bytedance.common.utility.Logger;
import com.bytedance.common.utility.NetworkType;
import com.bytedance.common.utility.UIUtils;
import com.bytedance.common.utility.c.SharedPreferenceCompat;
import com.bytedance.common.utility.collection.WeakHandler;
import com.bytedance.frameworks.baselib.network.http.util.TaskInfo;
import com.ss.android.account.Spipe;
import com.ss.android.action.ArticleActionHelper;
import com.ss.android.action.a.a.Comment;
import com.ss.android.action.a.c.ShareDialog;
import com.ss.android.article.base.app.AppData;
import com.ss.android.article.base.feature.app.b.DBHelper;
import com.ss.android.article.base.feature.app.c.ImageManager;
import com.ss.android.article.base.feature.app.schema.AdsAppActivity;
import com.ss.android.article.base.feature.detail.model.ArticleDetail;
import com.ss.android.article.base.feature.detail.model.ArticleInfo;
import com.ss.android.article.base.feature.detail.model.ArticleInfo.VideoExtendLink;
import com.ss.android.article.base.feature.detail.model.CommentWrapper;
import com.ss.android.article.base.feature.detail.presenter.ActivityStackManager;
import com.ss.android.article.base.feature.detail.presenter.ActivityStackManager.Type;
import com.ss.android.article.base.feature.detail.presenter.ArticleTabComment;
import com.ss.android.article.base.feature.detail.presenter.ArticleTabCommentsRequestTask;
import com.ss.android.article.base.feature.detail.presenter.CommentFetcher;
import com.ss.android.article.base.feature.detail.presenter.CommentTabCache;
import com.ss.android.article.base.feature.detail.presenter.DetailHelper;
import com.ss.android.article.base.feature.detail.presenter.DetailLoader;
import com.ss.android.article.base.feature.detail2.DetailPageListener;
import com.ss.android.article.base.feature.detail2.SSPage;
import com.ss.android.article.base.feature.detail2.b.NewDetailAdapter;
import com.ss.android.article.base.feature.detail2.bb;
import com.ss.android.article.base.feature.detail2.video.a.NewVideoFragmentHelper;
import com.ss.android.article.base.feature.detail2.video.a.VideoDetailExtraHolder;
import com.ss.android.article.base.feature.detail2.view.NewDetailActivity;
import com.ss.android.article.base.feature.e.ArticleShareHelper;
import com.ss.android.article.base.feature.e.VideoAutoPlayHelperDetail;
import com.ss.android.article.base.feature.feed.FeedTab;
import com.ss.android.article.base.feature.feed.c.FeedDownloadAppAd;
import com.ss.android.article.base.feature.model.Article;
import com.ss.android.article.base.feature.model.CellRef;
import com.ss.android.article.base.feature.model.MediaInfo;
import com.ss.android.article.base.feature.model.RelatedVideoTouTiao;
import com.ss.android.article.base.feature.splash.SplashAdActivity;
import com.ss.android.article.base.feature.update.b.UpdateItemMgr;
import com.ss.android.article.base.feature.video.IMediaViewLayout.CtrlFlag;
import com.ss.android.article.base.feature.video.IVideoController;
import com.ss.android.article.base.feature.video.IVideoController.ICloseListener;
import com.ss.android.article.base.feature.video.IVideoController.IPlayCompleteListener;
import com.ss.android.article.base.feature.video.IVideoController.IShareListener;
import com.ss.android.article.base.feature.video.IVideoController.IThirdPartnerListner;
import com.ss.android.article.base.feature.video.IVideoControllerContext;
import com.ss.android.article.base.feature.video.IVideoFullscreen;
import com.ss.android.article.base.feature.video.ThirdVideoPartnerData;
import com.ss.android.article.base.feature.video.VideoPref;
import com.ss.android.article.base.ui.DiggAnimationView;
import com.ss.android.article.base.ui.NoDataViewFactory$ImgType;
import com.ss.android.article.base.ui.aa;
import com.ss.android.article.base.utils.ArticleHelper;
import com.ss.android.article.common.e.VideoControllerSupplierProxy;
import com.ss.android.b.a.BaseAdsData;
import com.ss.android.common.ad.MobAdClickCombiner;
import com.ss.android.common.app.AbsFragment;
import com.ss.android.common.app.IComponent;
import com.ss.android.common.app.WebViewTweaker;
import com.ss.android.common.app.permission.PermissionsManager;
import com.ss.android.common.app.permission.PermissionsResultAction;
import com.ss.android.common.applog.AppLog;
import com.ss.android.common.callback.CallbackCenter;
import com.ss.android.common.callback.SSCallback;
import com.ss.android.common.dialog.AlertDialog;
import com.ss.android.common.lib.MobClickCombiner;
import com.ss.android.common.ui.view.SwipeOverlayFrameLayout;
import com.ss.android.common.util.NetworkStatusMonitor;
import com.ss.android.common.util.NetworkUtils;
import com.ss.android.common.util.ToolUtils;
import com.ss.android.image.AvatarLoader;
import com.ss.android.image.BaseImageManager;
import com.ss.android.image.FrescoUtils;
import com.ss.android.image.loader.ImageLoader;
import com.ss.android.model.AbsArticle;
import com.ss.android.model.BaseArticle;
import com.ss.android.model.ItemType;
import com.ss.android.newmedia.BaseAppData;
import com.ss.android.newmedia.a.AbstractFooter;
import com.ss.android.newmedia.a.BrowserFragment;
import com.ss.android.newmedia.a.TimeFormatter;
import com.ss.android.newmedia.a.w;
import com.ss.android.newmedia.e.ShareHelper;
import com.ss.android.newmedia.f.Response;
import com.ss.android.newmedia.util.AppUtil;
import com.ss.android.newmedia.util.InfoLRUCache;

import org.json.JSONException;
import org.json.JSONObject;

import java.lang.ref.WeakReference;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.EnumSet;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Stack;

public final class NewVideoDetailFragment extends AbsFragment implements
        WeakHandler.Callback,
        ShareDialog.b$a,
        com.ss.android.article.base.feature.detail.presenter.a,
        DetailHelper.SimpleArticle,
        DetailLoader.Callback,
        NewDetailAdapter.a$a,
        bb,
        com.ss.android.article.base.feature.detail2.dd,
        SSPage,
        DetailPageListener,
        IVideoControllerContext,
        w {
    private static int D = 10;

    private final Map bq = new HashMap();
    public ArticleShareHelper mArticleShareHelper;
    public long f;
    public ArticleDetail mArticleDetail;
    public Article mArticle;
    public NewVideoFragmentHelper mNewVideoFragmentHelper;
    public Context context;
    protected Spipe m;
    int[] A;
    boolean B;
    com.ss.android.article.base.ui.NoNetView mNoNetView;
    BaseArticle b;
    boolean c = false;
    long d;
    String bundleDownloadAppLogExtra;
    AppData mAppData;
    int k = 0;
    int l = 0;
    boolean n;
    DetailHelper mDetailHelper;
    IVideoController mVideoController;
    IVideoFullscreen mVideoFullscreen;
    boolean r;
    boolean s;
    ThirdVideoPartnerData mThirdVideoPartnerData;
    MonitorFPS mMonitorFPS;
    BrowserFragment mBrowserFragment;
    View x;
    boolean y;
    boolean z;
    private boolean E = true;
    private long F = 0;
    private long G = 0;
    private long H = 0;
    private long mSearchResultId = 0;
    private String mSource;
    private String mQuery;
    private boolean L;
    private long M;
    private int N;
    private long O;
    private String P;
    private int Q;
    private String R;
    private boolean S = false;
    private SwipeOverlayFrameLayout mSwipeOverlayFrameLayout;
    private Resources U;
    private ViewGroup mVideoDetailLayout;
    private FrameLayout mTopVideoHolder;
    private DiggAnimationView mDiggAnimationView;
    private ArticleActionHelper mArticleActionHelper;
    private VideoAutoPlayHelperDetail mVideoAutoPlayHelperDetail;
    private ImageLoader mImageLoader;
    private int aB;
    private TaskInfo aC;
    private BaseImageManager mBaseImageManager;
    private NetworkStatusMonitor mNetworkStatusMonitor;
    private String aF;
    private int aG;
    private int aH;
    private ICloseListener mCloseListener = new ICloseListener() {

        public final void onClose(boolean arg10) {
            if (!NewVideoDetailFragment.this.isHostActivityDead()) {
                if (arg10) {
                    try {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("enter_from", NewVideoDetailFragment.this.getEnterFrom());
                        MobClickCombiner.onEvent(NewVideoDetailFragment.this.context, "detail", "page_close_button", NewVideoDetailFragment.this.f, 0, jsonObject);
                    } catch (JSONException v0) {
                    }

                    NewVideoDetailFragment.this.p();
                    return;
                }

                if (NewVideoDetailFragment.this.mVideoController != null && (NewVideoDetailFragment.this.mVideoController.isVideoVisible())) {
                    NewVideoDetailFragment.this.mVideoController.releaseMedia();
                }
            }
        }
    };
    private VideoDetailExtraHolder.g$a aJ = new VideoDetailExtraHolder.g$a(this);
    private SSCallback aK = new SSCallback() {

        public final Object onCallback(Object[] args) {
            if (args[0] == BaseAppData.callbackTypeAddArticleCommentFromUpdate) {
                long v2 = ((Long) args[1]).longValue();
                Object v0 = args[2];
                if (v2 == NewVideoDetailFragment.this.f) {
                    NewVideoDetailFragment.this.a(((Comment) v0));
                }
            }

            return null;
        }
    };
    private SSCallback aL = new SSCallback() {

        public final Object onCallback(Object[] args) {
            if (args[0] == BaseAppData.callbackTypeVideoSubOrUnsub && (AppData.getInstance().getAbSettings().isAppLogNew())) {
                boolean v1 = ((Boolean) args[1]).booleanValue();
                Object v0 = args[2];
                JSONObject jsonObject = new JSONObject();
                try {
                    if (v0 != null) {
                        jsonObject.put("to_user_id", ((Article) v0).getUserId());
                    }
                    jsonObject.put("follow_type", "from_group");
                    jsonObject.put("source", "article_detail");
                    jsonObject.put("server_source", 30);
                    jsonObject.put("position", "title_below");
                } catch (JSONException jsonException) {
                }
                String v0_2 = v1 ? "rt_follow" : "rt_unfollow";
                NewVideoDetailFragment.a(NewVideoDetailFragment.this, v0_2, jsonObject, NewVideoDetailFragment.this.b);
            }

            return null;
        }
    };
    private int aM = 0;
    private LayoutInflater mLayoutInflater;
    private int aO;
    private int aP;
    private int aQ;
    private int aR;
    private ImageLoader aS;
    private ImageLoader aT;
    private Comment aU = null;
    private InfoLRUCache aV;
    private InfoLRUCache aW;
    private DetailLoader aX;
    private boolean aY = false;
    private ArrayList aZ = new ArrayList();
    private boolean aa;
    private Stack ab;
    private boolean ac = false;
    private Stack ad;
    private boolean ae = false;
    private boolean af = true;
    private String ag = null;
    private JSONObject mLogPb;
    private boolean ai = true;
    private boolean aj = false;
    private boolean ak = false;
    private boolean al = false;
    private boolean am = false;
    private String an = null;
    private int ao = 1;
    private String ap = null;
    private long aq = 0;
    private long ar = 0;
    private boolean as = false;
    private boolean at = false;
    private boolean au = false;
    private boolean av = false;
    private boolean aw = false;
    private WeakHandler ax = new WeakHandler(((WeakHandler.Callback) this));
    private AvatarLoader ay;
    private AvatarLoader az;
    private int ba;
    private String bb;
    private Animation bc;
    private Animation bd;
    private Runnable be = new Runnable() {

        public final void run() {
            if (NewVideoDetailFragment.this.getActivity() != null) {
                ((NewDetailActivity) NewVideoDetailFragment.this.getActivity()).h(NewVideoDetailFragment.this.r);
            }
        }
    };
    private boolean bf = false;
    private int bg = -1;
    private boolean bh;
    private long bi;
    private boolean bj = false;
    private boolean bk;
    private int mScreenWidth;
    private int bm = -2147483648;
    private IVideoFullscreen bn = new IVideoFullscreen() {
        @Override
        public final void onFullscreenChanged(boolean fullscreen) {
            if (!NewVideoDetailFragment.this.isHostActivityDead() && NewVideoDetailFragment.this.getCommentMode() == 0) {
                FragmentActivity fragmentActivity = NewVideoDetailFragment.this.getActivity();
                boolean detailToolbarVisible = !fullscreen;
                ((NewDetailActivity) fragmentActivity).setDetailToolBarVisible(detailToolbarVisible);
                NewVideoDetailFragment.this.m();
            }

            if (NewVideoDetailFragment.this.mVideoFullscreen != null) {
                NewVideoDetailFragment.this.mVideoFullscreen.onFullscreenChanged(fullscreen);
            }
        }
    };
    private IPlayCompleteListener mPlayCompleteListener = new IVideoController.IPlayCompleteListener() {

        public final void onItemShare(int channel) {
            if (channel > 0) {
                Article article = NewVideoDetailFragment.this.mArticle;
                IVideoController videoController = NewVideoDetailFragment.this.getVideoController();
                String v0 = "notfullscreen";
                if (videoController != null) {
                    v0 = videoController.isFullScreen() ? "fullscreen" : "notfullscreen";
                }

                if (NewVideoDetailFragment.this.mArticleShareHelper == null) {
                    return;
                }

                if (article == null) {
                    return;
                }

                JSONObject jsonObject = new JSONObject();
                try {
                    jsonObject.put("source_type", "video");
                    jsonObject.put("section", "detail_video_over");
                    jsonObject.put("fullscreen", v0);
                    jsonObject.put("icon_seat", "exposed");
                } catch (JSONException v0_1) {
                }

                NewVideoDetailFragment.this.mArticleShareHelper.fillShareParams(jsonObject);
                NewVideoDetailFragment.this.mArticleShareHelper.position = "detail";
                NewVideoDetailFragment.this.mArticleShareHelper.share(channel, article);
            }
        }

        public final void onReplay() {
        }

        public final void onShare() {
            NewVideoDetailFragment.this.d(false);
        }
    };
    private IShareListener mShareListener = new a$b(this);
    private IThirdPartnerListner mThirdPartnerListner = new IVideoController.IThirdPartnerListner() {

        @Override
        public void onClick() {
            NewVideoDetailFragment.this.e(true);
        }

        public final void onShowEvent(String arg2) {
            NewVideoDetailFragment.this.b(arg2);
        }
    };
    private boolean bs;

    static void a(NewVideoDetailFragment newVideoDetailFragment, String arg7) {
        String v0 = newVideoDetailFragment.J();
        if (v0 != null && (v0.equals("click_" + newVideoDetailFragment.R))) {
            v0 = "click_category";
        }

        JSONObjectWrapper objectWrapper = new JSONObjectWrapper();
        String v4 = "media_id";
        long v2 = newVideoDetailFragment.mArticle.mediaInfo != null ? newVideoDetailFragment.mArticle.mediaInfo.id : 0;
        JSONObjectWrapper jsonObjectWrapper = objectWrapper.put(v4, Long.valueOf(v2))
                .put("item_id", Long.valueOf(newVideoDetailFragment.mArticle.itemId))
                .put("enter_from", v0);
        if (AppData.getInstance().getAbSettings().isApplogStaging()) {
            jsonObjectWrapper.put("_staging_flag", Integer.valueOf(1));
        }

        jsonObjectWrapper.put(null);
        android.support.design.a.onEvent(arg7, jsonObjectWrapper.jo);
    }

    static void a(NewVideoDetailFragment arg0, String arg1, JSONObject arg2, BaseArticle arg3) {
        arg0.a(arg1, arg2, arg3);
    }

    private static void a(List<CommentWrapper> arg5) {
        if (arg5 != null && arg5.size() != 0) {
            int v1;
            for (v1 = 0; v1 < arg5.size(); ++v1) {
                Object v0 = arg5.get(v1);
                ((CommentWrapper) v0).e = 0;
                if (((CommentWrapper) v0).cellType != 1 && v1 > 0) {
                    v0 = arg5.get(v1 - 1);
                    if (((CommentWrapper) v0).cellType == 1) {
                        ((CommentWrapper) v0).e = 1;
                    }
                }

                if (v1 == arg5.size() - 1) {
                    arg5.get(v1).e = 2;
                }
            }
        }
    }

    public final void onUserClickCloseBtn() {
    }

    public final void onInfoBackClick() {
        this.G();
    }

    public final void onWriteCommentClick() {
        VideoAutoPlayHelperDetail.a(this.getVideoController());
        this.a("write_button");
        this.H();
    }

    public final void onCommentLayoutClick() {
        this.a(false, 4, false, true);
    }

    public final void onFavorBtnClick() {
        Article v0 = this.mArticle;
        if (v0 != null) {
            this.r();
        }

        if ((this.mAppData.j()) && v0 != null && (v0.userRepin)) {
            this.a(this.context, 2);
        }
    }

    public final void onShare() {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("source_type", "video");
            jsonObject.put("section", "detail_bottom_bar");
            jsonObject.put("fullscreen", "notfullscreen");
            jsonObject.put("icon_seat", "inside");
        } catch (JSONException v1) {
        }

        this.mArticleShareHelper.position = "detail";
        this.mArticleShareHelper.fillShareParams(jsonObject);
        VideoAutoPlayHelperDetail.a(this.getVideoController());
        if (this.mAppData.getAbSettings().isQQTopShare()) {
            this.d(true);
        } else {
            this.d(false);
        }
    }

    private void G() {
        if (!this.isHostActivityDead()) {
            NewVideoFragmentHelper v0 = this.mNewVideoFragmentHelper;
            if (v0 != null) {
                if (v0.mNewDetailAdapter.h) {
                    v0.mNewDetailAdapter.h = false;
                }

                if (this.mArticle != null && this.mArticle.commentCount == 0) {
                    this.H();
                }

                if (v0.l) {
                    return;
                }

                v0.l = true;
                if (!v0.mNewDetailAdapter.hasComments()) {
                    return;
                }

                if (v0.mCommentTabCache == null) {
                    return;
                }

                this.a(v0, v0.mCommentTabCache);
            }
        }
    }

    private void H() {
        Article v0 = this.mArticle;
        if (v0 != null) {
            if (((AbsArticle) v0).mBanComment) {
                if (!this.isHostActivityDead()) {
                    ((NewDetailActivity) this.getActivity()).setWriteCommentEnabled(false);
                }
            } else if (this.mDetailHelper != null) {
                this.mDetailHelper.a("", 0, true);
            }
        }
    }

    private void I() {
        int v2 = View.INVISIBLE;
        int v1 = 0;
        int v0 = 1;
        NewVideoFragmentHelper v3 = this.mNewVideoFragmentHelper;
        if (v3 != null && v3.mNightModeOverlay != null) {
            if (!v3.k) {
                v3.mNightModeOverlay.setVisibility(v2);
            } else {
                Article v4 = this.mArticle;
                if (v4 != null) {
                    if (v4.hasArticleUrl()) {
                        if (v3.m) {
                            if (!v4.d()) {
                            } else {
                                v0 = 0;
                            }
                        } else if (!v4.d()) {
                        } else {
                            v0 = 0;
                        }
                    } else {
                        v0 = 0;
                    }
                }

                View v3_1 = v3.mNightModeOverlay;
                if (v0 == 0) {
                    v1 = v2;
                }
                v3_1.setVisibility(v1);
            }
        }
    }

    private String J() {
        String v0 = this.an;
        if (android.support.design.a.isTextEmpty(v0)) {
            if (this.Q == 1) {
                if ("__all__".equals(this.R)) {
                    v0 = "click_headline";
                } else if (!android.support.design.a.isTextEmpty(this.R)) {
                    v0 = "click_" + this.R;
                }
            } else if (this.Q == 3) {
                v0 = "click_search";
            } else if (this.Q == 4) {
                v0 = "click_pgc_list";
            } else if (this.Q == 2) {
                v0 = "click_favorite";
            } else if (this.Q == 8) {
                v0 = "click_read_history";
            } else if (this.Q == 9) {
                v0 = "click_push_history";
            } else if (this.Q == 10) {
                v0 = "click_refresh_history";
            }
        }

        return v0;
    }

    private JSONObject K() {
        JSONObject v1_2;
        JSONObject v0 = null;
        try {
            if (android.support.design.a.isTextEmpty(this.ap)) {
            } else {
                v0 = new JSONObject(this.ap);
            }
            if (this.O > 0) {
                if (v0 == null) {
                    v0 = new JSONObject();
                }

                v0.put("from_gid", this.O);
                v1_2 = v0;
            } else {
                v1_2 = v0;
            }

            if (v1_2 == null) {
                v0 = new JSONObject();
                v0.put("log_pb", this.mLogPb);
            } else {
                v0 = v1_2;
            }
            if (this.R != null) {
                v0.put("category_name", this.R);
            }

            if (this.mArticle == null) {
                return v0;
            }

            v0.put("user_id", this.mArticle.getUserId());
        } catch (JSONException v1) {
        }

        return v0;
    }

    public final boolean L() {
        return this.r;
    }

    private void M() {
        if (this.mNewVideoFragmentHelper != null && this.mNewVideoFragmentHelper.mFooter != null && this.mNewVideoFragmentHelper.mFooter.mFooterContent != null && !NetworkUtils.isNetworkAvailable(this.getContext())) {
            if (this.mNoNetView == null) {
                this.mNoNetView = android.support.design.a.a(this.getContext(), this.mNewVideoFragmentHelper.mFooter.mFooterContent,
                        com.ss.android.article.base.ui.ac.a(NoDataViewFactory$ImgType.NOT_NETWORK),
                        com.ss.android.article.base.ui.ad.a(this.getString(com.ss.android.article.browser.R.string.not_network_tip)),
                        com.ss.android.article.base.ui.ab.a(new aa(this.getString(com.ss.android.article.browser.R.string.label_retry), new View.OnClickListener() {

                            public final void onClick(View view) {
                                if ((NewVideoDetailFragment.this.mNewVideoFragmentHelper.mFooter instanceof NewVideoDetailFragment.a$a)) {
                                    NewVideoDetailFragment.this.mNewVideoFragmentHelper.mFooter.onUserClick();
                                }
                            }
                        })));
            }

            this.mNoNetView.initNoDataActionBtn();
            this.mNoNetView.setVisibility(View.VISIBLE);
            this.mNewVideoFragmentHelper.mFooter.hide();
        }
    }

    public final void a(int expectVideoStatus, NewVideoFragmentHelper newVideoFragmentHelper) {
        if (this.mVideoController == null) {
            this.bg = -1;
        } else if (this.mVideoController.isVideoPaused()) {
            this.bg = 2;
        } else if (this.mVideoController.isVideoPlaying()) {
            this.bg = 1;
        }

        if (this.bg != expectVideoStatus) {
            Article article = this.mArticle;
            if (article != null && newVideoFragmentHelper != null) {
                int v1_1;
                if (article != null && newVideoFragmentHelper != null) {
                    if (this.mScreenWidth == 0) {
                        this.mScreenWidth = UIUtils.getScreenWidth(this.getContext());
                    }
                    v1_1 = ArticleHelper.getActualLargeImageHeight(article.mLoadingCoverImageInfo, this.mScreenWidth, false, this.aM);
                    if (this.bm != v1_1) {
                        int v4 = -3;
                        if (newVideoFragmentHelper != null && newVideoFragmentHelper.mVideoDetailExtraHolder != null) {
                            this.initVideoCoverLayout(newVideoFragmentHelper);
                            Log.d("travis", "NewVideoDetailFragment:::setVisibility() visible  #1");
                            UIUtils.setVisibility(newVideoFragmentHelper.mVideoDetailExtraHolder.mVideoCoverLayout, View.VISIBLE);
                            UIUtils.setLayoutParams(newVideoFragmentHelper.mVideoDetailExtraHolder.mVideoCoverLayout, v4, v1_1);
                        }
                        UIUtils.setLayoutMargins(this.mSwipeOverlayFrameLayout, v4, v1_1, v4, v4);
                        this.bm = v1_1;
                    }
                }
                v1_1 = this.bm;
                switch (expectVideoStatus) {
                    case 1:
                        String videoId = article.videoId;
                        if (this.getVideoController() != null && !android.support.design.a.isTextEmpty(videoId)) {
                            if (!this.mVideoController.isVideoPlaying()) {
                                this.checkConnectAndPlay(videoId, this.mScreenWidth, v1_1);
                            }
                            this.bg = 1;
                            break;
                        }
                        this.bg = -1;
                        break;
                    case 2:
                        if (this.mVideoController != null) {
                            if ((this.mVideoController.isVideoPlaying()) && !this.mVideoController.isFullScreen()) {
                                this.mVideoController.pauseVideo();
                            } else if (this.mVideoController.isVideoVisible()) {
                                this.mVideoController.releaseMedia();
                                this.bk = true;
                            }
                        }
                        this.bg = 2;
                        break;
                    case 3:
                        if (this.mVideoController == null || !this.mVideoController.isVideoPaused()) {
                            this.checkConnectAndPlay(this.aF, this.mScreenWidth, v1_1);
                        } else {
                            this.mVideoController.resumeVideo();
                        }

                        this.bg = 1;
                        break;
                    case 4:
                        if (this.mVideoController != null && (this.mVideoController.isVideoVisible())) {
                            this.mVideoController.releaseMedia();
                        }
                        this.bg = 4;
                        break;
                    default:
                        this.bg = -1;
                        return;
                }
                if (this.bg == 2) {
                    return;
                }

                if (!this.bk) {
                    return;
                }

                this.bk = false;
                return;
            }

            this.bg = -1;
        }
    }

    final void a(NewVideoFragmentHelper newVideoFragmentHelper, CommentTabCache commentTabCache) {
        if (newVideoFragmentHelper != null && commentTabCache != null) {
            if (commentTabCache.mArticleTabComments[0].isEmpty()) {
                newVideoFragmentHelper.mFooter.hideFooterContent();
                boolean banComment = commentTabCache.mArticleTabComments[0].banComment;
                if (!banComment && this.mArticle != null) {
                    banComment = this.mArticle.mBanComment;
                }

                com.ss.android.article.base.feature.detail2.video.a.l v2 = newVideoFragmentHelper.e;
                banComment = !banComment;
                v2.a(banComment);
            } else {
                newVideoFragmentHelper.mFooter.setViewMoreText(com.ss.android.article.browser.R.string.ss_load_more);
                if (commentTabCache.mArticleTabComments[0].hasMore) {
                    newVideoFragmentHelper.mFooter.switchToMoreContent();
                } else {
                    newVideoFragmentHelper.mFooter.hideFooterContent();
                }
                newVideoFragmentHelper.e.a(false);
            }

            if (commentTabCache.load[0]) {
                newVideoFragmentHelper.mFooter.switchToLoading();
            }
            newVideoFragmentHelper.mNewDetailAdapter.addAllComment(commentTabCache.mArticleTabComments[0].commentWrapperList);
            newVideoFragmentHelper.mNewDetailAdapter.notifyDataSetChanged();
        }
    }

    private void showImageToast(int drawableResId, int stringResId) {
        if (!this.isHostActivityDead()) {
            android.support.design.a.showImageToast(this.getContext(), stringResId, drawableResId);
        }
    }

    private void a(long arg10) {
        if (this.mNewVideoFragmentHelper != null && this.mNewVideoFragmentHelper.mCommentTabCache != null && (this.mAppData.commentLoadMultiTab())) {
            ArticleTabComment articleTabComment = this.mNewVideoFragmentHelper.mCommentTabCache.mArticleTabComments[1];
            if (!articleTabComment.hasComment) {
                CommentFetcher commentFetcher = new CommentFetcher(articleTabComment.increateCounter(), this.mArticle, 1, 0, arg10);
                this.aX.loadComment(commentFetcher.getItemKey(), commentFetcher);
                this.mNewVideoFragmentHelper.mCommentTabCache.load[1] = true;
            }
        }
    }

    private void a(Context arg7, int arg8) {
        int v2 = 2;
        if (arg8 != 1) {
            if (arg8 != v2) {
                return;
            }

            if (this.m.isLogin) {
                return;
            }

            if (!this.mAppData.j()) {
                return;
            }

            AlertDialog.Builder builder = com.ss.android.j.b.createDialogBuilder(this.getActivity());
            builder.setMessage(com.ss.android.article.browser.R.string.ry);
            builder.setPositiveButton(com.ss.android.article.browser.R.string.rx, new DialogInterface.OnClickListener() {

                public final void onClick(DialogInterface dialogInterface, int which) {
                    if (NewVideoDetailFragment.this.isViewValid()) {
                        dialogInterface.dismiss();
                    }

                    NewVideoDetailFragment.this.mAppData.k();
                    Spipe.a(((NewDetailActivity) NewVideoDetailFragment.this.getActivity()), (Bundle) null);
                    MobClickCombiner.onEvent(NewVideoDetailFragment.this.getActivity(), "auth", "login_detail_favor_done");
                }
            });
            builder.setNegativeButton(com.ss.android.article.browser.R.string.label_cancel,
                    new DialogInterface.OnClickListener() {

                        public final void onClick(DialogInterface dialogInterface, int which) {
                            if (NewVideoDetailFragment.this.isViewValid()) {
                                dialogInterface.dismiss();
                            }

                            MobClickCombiner.onEvent(NewVideoDetailFragment.this.getActivity(), "auth", "login_detail_favor_cancel");
                        }
                    });
            MobClickCombiner.onEvent(this.getActivity(), "auth", "login_detail_favor");
            builder.setCancelable(true);
            if (this.isViewValid()) {
                builder.show();
            }

            this.mAppData.unloginFaverFirst = false;
        } else if (!this.m.isLogin && (this.mAppData.l())) {
            View.OnClickListener v1 = new View.OnClickListener() {

                public final void onClick(View arg6) {
                    NewVideoDetailFragment.this.mAppData.k();
                    if (NewVideoDetailFragment.this.mDetailHelper != null) {
                        NewVideoDetailFragment.this.mDetailHelper.a("", 0, true);
                    }
                }
            };
            com.ss.android.article.base.feature.app.bb v0 = null;
            if (arg8 == 1) {
                v0 = new com.ss.android.article.base.feature.app.bb(arg7, "login_detail_comment");
                v0.a(0, com.ss.android.article.browser.R.string.rv, com.ss.android.article.browser.R.string.rt);
                v0.a(com.ss.android.article.browser.R.string.rs, ((View.OnClickListener) v1));
            } else if (arg8 == v2) {
                v0 = new com.ss.android.article.base.feature.app.bb(arg7, "login_detail_favor");
                v0.a(com.ss.android.article.browser.R.drawable.nq, com.ss.android.article.browser.R.string.rw, com.ss.android.article.browser.R.string.ru);
                v0.a(com.ss.android.article.browser.R.string.rr, ((View.OnClickListener) v1));
            }

            if (v0 != null && arg7 != null && (this.isViewValid())) {
                v0.show();
                this.mAppData.unloginFaverFirst = false;
            }

            this.mAppData.a(System.currentTimeMillis());
            this.mAppData.m();
        }
    }

    private void onArticleDetailLoadedFromInternet(ArticleDetail articleDetail) {
        if (articleDetail == null || !articleDetail.delete) {
            if (this.aa) {
                this.aa = false;
                if (!this.aj) {
                    this.a("enter");
                    this.aj = true;
                }
            }

            Article article = this.mArticle;
            if (articleDetail != null) {
                article.mediaUserId = articleDetail.mediaUserId;
            }

            NewVideoFragmentHelper newVideoFragmentHelper = this.mNewVideoFragmentHelper;
            this.a(article, newVideoFragmentHelper, articleDetail);
            if (this.mArticle != null && this.mArticle.middleImage != null && this.mArticle.middleImage.mImage != null && !android.support.design.a.isTextEmpty(this.mArticle.middleImage.mImage.url)) {
                FrescoUtils.preload(Uri.parse(this.mArticle.middleImage.mImage.url), this.context);
            }

            if (articleDetail != null && !TextUtils.isEmpty(articleDetail.content)) {
                this.mArticleDetail = articleDetail;
                UIUtils.setVisibility(this.mNewVideoFragmentHelper.mContentLayout, 0);
                newVideoFragmentHelper.mDetailErrorView.hideSelf();
                if (newVideoFragmentHelper.m) {
                    this.F = System.currentTimeMillis();
                    this.b = new BaseArticle(article.groupId, article.itemId, article.aggrType);
                    this.G = this.d;
                } else {
                }

                return;
            }

            if (this.mNewVideoFragmentHelper == null) {
                return;
            }

            this.mNewVideoFragmentHelper.mDetailErrorView.showNoDataUI(false);
        } else if (!this.isHostActivityDead()) {
            ((NewDetailActivity) this.getActivity()).switchToArticleDeleted(this.mArticle);
        }
    }

    final void a(String arg3) {
        MobClickCombiner.onEvent(this.getContext(), "detail", arg3);
    }

    private void a(Article article, NewVideoFragmentHelper newVideoFragmentHelper, ArticleDetail articleDetail) {
        if (article != null && newVideoFragmentHelper != null && newVideoFragmentHelper.mVideoDetailExtraHolder != null) {
            newVideoFragmentHelper.mDetailErrorView.hideSelf();
            UIUtils.setVisibility(newVideoFragmentHelper.mNightModeOverlay, 8);
            if ((this.bh) && newVideoFragmentHelper.mListView != null) {
                this.bh = false;
                if (this.mNewVideoFragmentHelper != null
                        && this.mNewVideoFragmentHelper.mListView != null
                        && this.mNewVideoFragmentHelper.mListView.getVisibility() != View.GONE) {
                    this.mNewVideoFragmentHelper.mListView.setSelection(0);
                    this.k = this.mNewVideoFragmentHelper.mListView.getFirstVisiblePosition();
                    if (this.mNewVideoFragmentHelper.mListView.getChildAt(0) != null) {
                        this.l = this.mNewVideoFragmentHelper.mListView.getChildAt(0).getTop();
                    }
                }
            }

            boolean v0 = article.directPlay;
            boolean v2;
            Article v1;
            if (article.delete) {
                v1 = null;
                v2 = false;
            } else {
                v2 = v0;
                v1 = article;
            }

            final VideoDetailExtraHolder videoDetailExtraHolder = newVideoFragmentHelper.mVideoDetailExtraHolder;
            VideoDetailExtraHolder.g$a v0_1 = this.aJ;
            videoDetailExtraHolder.mArticle = v1;
            videoDetailExtraHolder.K = v0_1;
            int v6;
            int v0_2;
            if (videoDetailExtraHolder.mArticle == null) {
                UIUtils.setVisibility(videoDetailExtraHolder.h, 8);
            } else {
                UIUtils.setVisibility(videoDetailExtraHolder.h, 0);
                videoDetailExtraHolder.mVideoTitleTv.setText(videoDetailExtraHolder.mArticle.title);
                com.ss.android.article.base.feature.detail2.config.a.a(2, videoDetailExtraHolder.mVideoTitleTv);
                com.ss.android.article.base.feature.detail2.config.a.b(2, videoDetailExtraHolder.mVideoTitleTv);
                Context v3 = videoDetailExtraHolder.mContext;
                v0_2 = videoDetailExtraHolder.mArticle.isLiveVideo() ? com.ss.android.article.browser.R.string.video_live_watch_count : com.ss.android.article.browser.R.string.video_watch_count;
                UIUtils.setTextAndVisibility(videoDetailExtraHolder.mWatchCountTv, v3.getString(v0_2, new Object[]{Integer.valueOf(videoDetailExtraHolder.mArticle.videoWatchCount)}));
                List v0_3 = videoDetailExtraHolder.mArticle.zzcomment;
                if (v0_3 != null && !v0_3.isEmpty()) {
                    videoDetailExtraHolder.mWatchCountDivider.setVisibility(View.VISIBLE);
                    videoDetailExtraHolder.mTxtReprintPGC.setVisibility(View.VISIBLE);
                    videoDetailExtraHolder.mTxtReprintPGC.getViewTreeObserver().addOnGlobalLayoutListener(new com.ss.android.article.base.feature.detail2.video.a.k(videoDetailExtraHolder, v0_3, videoDetailExtraHolder.mContext.getResources().getString(com.ss.android.article.browser.R.string.recomend)));
                }

                String v0_4 = videoDetailExtraHolder.mArticle._abstract;
                if (!android.support.design.a.isTextEmpty(v0_4) && ("...".equals(v0_4.trim()))) {
                    v0_4 = "";
                }

                if (videoDetailExtraHolder.mArticle.publishTime > 0) {
                    String v3_1 = new SimpleDateFormat(videoDetailExtraHolder.mContext.getString(com.ss.android.article.browser.R.string.video_publish_prefix)).format(new Date(videoDetailExtraHolder.mArticle.publishTime * 1000));
                    v0_4 = android.support.design.a.isTextEmpty(v0_4) ? v3_1 : v3_1 + "·" + v0_4;
                }

                videoDetailExtraHolder.mVideoContentTv.setText(((CharSequence) v0_4));
                boolean v3_2 = android.support.design.a.isTextEmpty(v0_4);
                ImageView v5 = videoDetailExtraHolder.mExpandBtn;
                v0_2 = v3_2 ? 8 : 0;
                UIUtils.setVisibility(v5, v0_2);
                TextView v5_1 = videoDetailExtraHolder.mVideoTitleTv;
                v6 = -3;
                int v7 = -3;
                v0_2 = v3_2 ? videoDetailExtraHolder.mContext.getResources().getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.detail_info_padding) : 0;
                UIUtils.setLayoutMargins(((View) v5_1), v6, v7, v0_2, -3);
                videoDetailExtraHolder.mDiggLayout.setText(android.support.design.a.c(videoDetailExtraHolder.mArticle.diggCount));
                videoDetailExtraHolder.mBuryLayout.setText(android.support.design.a.c(videoDetailExtraHolder.mArticle.buryCount));
                videoDetailExtraHolder.a(false, videoDetailExtraHolder.mDiggLayout, videoDetailExtraHolder.mBuryLayout, false);
                TextView v3_3 = videoDetailExtraHolder.mPraiseBtn;
                v0_2 = articleDetail == null || !articleDetail.canBePraised ? 8 : 0;
                UIUtils.setVisibility(v3_3, v0_2);
                ViewGroup.LayoutParams v0_5;
                if (videoDetailExtraHolder.mPraiseBtn == null || videoDetailExtraHolder.mPraiseBtn.getVisibility() != View.VISIBLE) {
                    v0_5 = videoDetailExtraHolder.mVideoExtendLinkText.getLayoutParams();
                    ((RelativeLayout.LayoutParams) v0_5).addRule(1, com.ss.android.article.browser.R.id.bury_layout);
                    ((RelativeLayout.LayoutParams) v0_5).leftMargin = 0;
                    videoDetailExtraHolder.mVideoExtendLinkText.setLayoutParams(v0_5);
                } else {
                    v0_5 = videoDetailExtraHolder.mVideoExtendLinkText.getLayoutParams();
                    ((RelativeLayout.LayoutParams) v0_5).addRule(1, com.ss.android.article.browser.R.id.praise_btn);
                    ((RelativeLayout.LayoutParams) v0_5).leftMargin = ((int) UIUtils.dp2px(videoDetailExtraHolder.mContext, 23f));
                    videoDetailExtraHolder.mVideoExtendLinkText.setLayoutParams(v0_5);
                }

                if (v1 == null) {
                    Log.d("travis", "NewVideoDetailFragment:::setVisibility() gone  #2");
                    UIUtils.setVisibility(videoDetailExtraHolder.mVideoCoverLayout, View.GONE);
                } else {
                    Log.d("travis", "NewVideoDetailFragment:::setVisibility() visible  #3");
                    UIUtils.setVisibility(videoDetailExtraHolder.mVideoCoverLayout, View.VISIBLE);
                    UIUtils.setTextAndVisibility(videoDetailExtraHolder.mCoverTitle, v1.title);
                    String durationTxt = ArticleHelper.convert2ReadableString(v1.videoDuration);
                    if (v1.videoDuration == 0) {
                        videoDetailExtraHolder.mCoverDuration.setVisibility(View.GONE);
                    } else {
                        videoDetailExtraHolder.mCoverDuration.setVisibility(View.VISIBLE);
                        videoDetailExtraHolder.mCoverDuration.setText(durationTxt, true);
                    }
                    UIUtils.setTextAndVisibility(videoDetailExtraHolder.mCoverSource, v1.source);
                    videoDetailExtraHolder.mCoverPlayIcon.setOnClickListener(videoDetailExtraHolder.O);
                    videoDetailExtraHolder.mCoverBack.setOnClickListener(videoDetailExtraHolder.O);
                    Log.d("travis", "NewVideoDetailFragment:::loadImage()  mLoadingCoverImageInfo= " + v1.mLoadingCoverImageInfo.toJsonObj());
                    videoDetailExtraHolder.mImageLoader.loadImage(videoDetailExtraHolder.mCoverImage, v1.mLoadingCoverImageInfo, false);
                }
            }
            v0_2 = articleDetail == null || !articleDetail.isOriginal ? 0 : 1;
            if (v0_2 != 0) {
                videoDetailExtraHolder.mVideoTitleTv.getViewTreeObserver()
                        .addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {

                            public final boolean onPreDraw() {
                                int v0 = 0;
                                if (videoDetailExtraHolder.mArticle != null) {
                                    videoDetailExtraHolder.mVideoTitleTv.getViewTreeObserver().removeOnPreDrawListener(((ViewTreeObserver.OnPreDrawListener) this));
                                    if (videoDetailExtraHolder.mVideoTitleTv.getLineCount() == 1) {
                                        videoDetailExtraHolder.mVideoTitleTv.setText(videoDetailExtraHolder.a(videoDetailExtraHolder.mArticle.title));
                                        return true;
                                    }

                                    try {
                                        Drawable v1 = videoDetailExtraHolder.mContext.getResources().getDrawable(com.ss.android.article.browser.R.drawable.t1);
                                        int v2 = videoDetailExtraHolder.mVideoTitleTv.getLayout().getLineEnd(1) - videoDetailExtraHolder.mVideoTitleTv.getLayout().getLineStart(1) + 1;
                                        float v3 = videoDetailExtraHolder.mVideoTitleTv.getTextSize();
                                        float v4 = (((float) videoDetailExtraHolder.mVideoTitleTv.getWidth())) - (((float) v2)) * v3;
                                        float v1_1 = (((float) v1.getIntrinsicWidth())) + UIUtils.dp2px(videoDetailExtraHolder.mContext, 6f);
                                        if (v4 < v1_1) {
                                            String v4_1 = videoDetailExtraHolder.mVideoTitleTv.getText().toString();
                                            Paint paint = new Paint();
                                            int v6 = videoDetailExtraHolder.mVideoTitleTv.getWidth() - videoDetailExtraHolder.mVideoTitleTv.getPaddingLeft() - videoDetailExtraHolder.mVideoTitleTv.getPaddingRight();
                                            while (v0 < v2) {
                                                if ((((float) v0)) * v3 + v1_1 + paint.measureText(Character.toString('…')) >= (((float) v6))) {
                                                    break;
                                                }

                                                ++v0;
                                            }

                                            videoDetailExtraHolder.mVideoTitleTv.setText(videoDetailExtraHolder.a(v4_1.substring(0, v0 - 2 + videoDetailExtraHolder.mVideoTitleTv.getLayout().getLineEnd(0)) + Character.toString('…')));
                                            return true;
                                        }

                                        videoDetailExtraHolder.mVideoTitleTv.setText(videoDetailExtraHolder.a(videoDetailExtraHolder.mArticle.title));
                                    } catch (Exception exception) {
                                        Logger.throwExceptionInDebug(exception);
                                    }
                                }

                                return true;
                            }
                        });
            }

            if (newVideoFragmentHelper.m) {
                return;
            }

            if (this.af) {
                v0_2 = v2 ? 1 : 4;
                this.a(v0_2, newVideoFragmentHelper);
            } else {
                this.a(4, newVideoFragmentHelper);
                IVideoController videoController = this.getVideoController();
                long v2_1 = this.bi;
                String v4_1 = this.R;
                int v5_2 = this.aG;
                v6 = this.aH;
                String v7_1 = this.an != null ? this.an : this.J();
                videoController.showBackwardVideo(v1, v2_1, v4_1, v5_2, v6, v7_1, this.P, this.d, this.bundleDownloadAppLogExtra);
            }

            if (articleDetail == null) {
                return;
            }

            if (TextUtils.isEmpty(articleDetail.content)) {
                return;
            }

            newVideoFragmentHelper.m = true;
            if (newVideoFragmentHelper == null) {
                return;
            }

            Article article1 = this.mArticle;
            if (!this.isActive()) {
                return;
            }

            if (article1 == null) {
                return;
            }

            if (this.b == null || this.b.groupId != article1.groupId) {
                this.x();
                this.F = 0;
                this.b = new BaseArticle(article1.groupId, article1.itemId, article1.aggrType);
            }

            this.G = this.d;
            if (this.F > 0) {
                return;
            }
            this.F = System.currentTimeMillis();
        }
    }

    private void a(NewVideoFragmentHelper arg12, boolean arg13) {
        int v10 = com.ss.android.article.browser.R.color.gq;
        int v9 = com.ss.android.article.browser.R.color.article_video_cover_txt_color;
        int v7 = com.ss.android.article.browser.R.color.article_detail_color;
        int v8 = com.ss.android.article.browser.R.color.ssxinzi3;
        if (arg12 != null && arg12.k != arg13) {
            arg12.k = arg13;
            com.ss.android.article.base.feature.detail2.video.a.l v3 = arg12.e;
            Resources resources = v3.g.getResources();
            boolean v0 = AppData.isNightMode();
            if (v3.G != v0) {
                v3.G = v0;
                com.ss.android.article.base.feature.detail2.config.a.a(v3.j, v3.g.getResources().getColor(v7));
                v3.F.setBackgroundResource(v7);
                v3.m.setBackgroundResource(com.ss.android.article.browser.R.drawable.bg_detail_action);
                v3.E.setTextColor(resources.getColor(com.ss.android.article.browser.R.color.update_comment_more_text_selector));
                LinearLayout v5 = v3.q;
                int v6 = v5.getChildCount();
                int v1;
                for (v1 = 0; v1 < v6; ++v1) {
                    ((com.ss.android.article.base.feature.detail2.video.a.e) v5.getChildAt(v1).getTag()).e();
                }

                v3.s.setTextColor(resources.getColorStateList(com.ss.android.article.browser.R.color.zi3));
                v3.s.setCompoundDrawablesWithIntrinsicBounds(0, 0, com.ss.android.article.browser.R.drawable.i2, 0);
                int v5_1 = v3.o.getChildCount();
                for (v1 = 0; v1 < v5_1; ++v1) {
                    ((com.ss.android.article.base.feature.detail.presenter.t) v3.o.getChildAt(v1).getTag()).a();
                }

                v3.l.setTextColor(resources.getColorStateList(com.ss.android.article.browser.R.color.ssxinzi8));
                if (v3.C != null) {
                    v3.C.adaptNightMode();
                }

                v0 = AppData.isNightMode();
                if (v3.k != null) {
                    v3.k.setTextColor(v3.g.getResources().getColor(com.ss.android.article.browser.R.color.ssxinzi2));
                }

                if (v3.u != null) {
                    v3.u.adaptNightMode(v0);
                }

                if (v3.v != null) {
                    v3.v.a();
                }

                if (v3.w != null) {
                    v3.w.adaptNightMode(v0);
                }

                if (v3.y != null) {
                    v3.y.adaptNightMode(v0);
                }

                if (v3.z != null) {
                    v3.z.adaptNightMode(v0);
                }

                if (v3.x != null) {
                    v3.x.adaptNightMode(v0);
                }

                if (v3.B != null) {
                    v3.B.adaptNightMode(v0);
                }

                if (v3.C != null) {
                    v3.C.adaptNightMode();
                }

                if (v3.A == null) {

                } else {
                    v3.A.adaptNightMode(v0);
                }
            }

            arg12.mListView.setBackgroundResource(v7);
            arg12.mSSMore.setTextColor(this.getResources().getColor(com.ss.android.article.browser.R.color.ly));
            arg12.mSSMore.setBackgroundResource(com.ss.android.article.browser.R.color.qm);
            if (arg12.mFooter.mFooterTopDivider != null) {
                arg12.mFooter.mFooterTopDivider.setBackgroundResource(v10);
            }

            if (arg12.mFooter.mFooterBottomDivider != null) {
                arg12.mFooter.mFooterBottomDivider.setBackgroundResource(v10);
            }

            if (arg12.mVideoDetailExtraHolder == null) {
                return;
            }

            VideoDetailExtraHolder videoDetailExtraHolder = arg12.mVideoDetailExtraHolder;
            boolean v3_1 = AppData.isNightMode();
            if (videoDetailExtraHolder.g == v3_1) {
                return;
            }

            videoDetailExtraHolder.g = v3_1;
            int v0_1 = ContextCompat.getColor(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.color.ssxinxian1);
            com.ss.android.article.base.feature.detail2.config.a.b(2, videoDetailExtraHolder.mVideoTitleTv, ContextCompat.getColor(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.color.ssxinzi1));
            videoDetailExtraHolder.mVideoContentTv.setTextColor(ContextCompat.getColor(videoDetailExtraHolder.mContext, v8));
            videoDetailExtraHolder.mExpandBtn.setImageResource(com.ss.android.article.browser.R.drawable.v1);
            videoDetailExtraHolder.mWatchCountTv.setTextColor(ContextCompat.getColor(videoDetailExtraHolder.mContext, v8));
            videoDetailExtraHolder.mWatchCountDivider.setBackgroundColor(videoDetailExtraHolder.mContext.getResources().getColor(com.ss.android.article.browser.R.color.ssxinxian9));
            videoDetailExtraHolder.mTxtReprintPGC.setTextColor(videoDetailExtraHolder.mContext.getResources().getColor(v8));
            videoDetailExtraHolder.mPGCInfoTopDivider.setBackgroundColor(v0_1);
            videoDetailExtraHolder.mPGCInfoBottomDivider.setBackgroundColor(v0_1);
            ImageView v4_1 = videoDetailExtraHolder.mPGCAvatarIv;
            ColorFilter v0_2 = v3_1 ? TTUtils.getNightModeColorFilter() : null;
            v4_1.setColorFilter(v0_2);
            videoDetailExtraHolder.mPGCNameTv.setTextColor(ContextCompat.getColorStateList(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.color.ssxinzi2_selector));
            videoDetailExtraHolder.mPGCVerifiedImage.setImageResource(com.ss.android.article.browser.R.drawable.all_newv);
            videoDetailExtraHolder.mSubscribeBtn.setTextColor(ContextCompat.getColorStateList(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.color.zi5));
            videoDetailExtraHolder.mSubscribeStatus.setImageResource(com.ss.android.article.browser.R.drawable.new_subscribe_video_details);
            videoDetailExtraHolder.mPraiseBtn.setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.money_video_details, 0, 0, 0);
            videoDetailExtraHolder.mPraiseBtn.setTextColor(ContextCompat.getColorStateList(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.color.zi3));
            videoDetailExtraHolder.mDiggLayout.adaptNightMode(v3_1);
            videoDetailExtraHolder.mBuryLayout.adaptNightMode(v3_1);
            videoDetailExtraHolder.mProgressBar.setIndeterminateDrawable(ContextCompat.getDrawable(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.drawable.video_detail_loading_progress));
            videoDetailExtraHolder.mVideoExtendLinkText.setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.salelink_video_icon, 0, 0, 0);
            if (videoDetailExtraHolder.mVideoCoverLayout != null) {
                videoDetailExtraHolder.mCoverTitle.setTextColor(ContextCompat.getColor(videoDetailExtraHolder.mContext, v9));
                videoDetailExtraHolder.mCoverSource.setTextColor(ContextCompat.getColor(videoDetailExtraHolder.mContext, v9));
                videoDetailExtraHolder.mCoverDuration.a(ContextCompat.getColorStateList(videoDetailExtraHolder.mContext, com.ss.android.article.browser.R.color.ssxinzi12), false);
                videoDetailExtraHolder.mCoverDuration.setBackgroundResource(com.ss.android.article.browser.R.drawable.video_time_length_bg);
                videoDetailExtraHolder.mCoverPlayIcon.setImageResource(com.ss.android.article.browser.R.drawable.playicon_video_selector);
                ImageView coverImage = videoDetailExtraHolder.mCoverImage;
                v0_2 = v3_1 ? TTUtils.getNightModeColorFilter() : null;
                coverImage.setColorFilter(v0_2);
                videoDetailExtraHolder.mCoverBack.setCompoundDrawablesWithIntrinsicBounds(com.ss.android.article.browser.R.drawable.shadow_btn_back, 0, 0, 0);
            }

            if (videoDetailExtraHolder.L == null) {
                return;
            }

            videoDetailExtraHolder.L.a();
        }
    }

    private void a(String arg12, JSONObject arg13, BaseArticle arg14) {
        String v10;
        long v4 = 0;
        JSONObjectWrapper v8 = new JSONObjectWrapper();
        String v1 = this.J();
        long v6 = arg14 != null ? arg14.itemId : v4;
        int v0 = arg14 != null ? arg14.aggrType : 0;
        String v9 = "group_id";
        long v2 = arg14 != null ? arg14.groupId : v4;
        v8.put(v9, Long.valueOf(v2)).put("item_id", Long.valueOf(v6)).put("aggr_type", Integer.valueOf(v0)).put("log_pb", this.mLogPb);
        String v0_1 = this.R;
        if (v1 == null) {
            v10 = v1;
            v1 = v0_1;
            v0_1 = v10;
        } else if (v1.equals("click_" + this.R)) {
            v0_1 = "click_category";
            v1 = this.R;
        } else if (v1.equals("click_headline")) {
            v10 = v1;
            v1 = this.R;
            v0_1 = v10;
        } else {
            v10 = v1;
            v1 = v1.replaceFirst("click_", "");
            v0_1 = v10;
        }

        v8.put("enter_from", v0_1).put("category_name", v1);
        if (AppData.getInstance().getAbSettings().isApplogStaging()) {
            v8.put("_staging_flag", Integer.valueOf(1));
        }

        if (this.mSearchResultId != v4) {
            v8.put("search_result_id", Long.valueOf(this.mSearchResultId)).put("source", this.mSource).put("query", this.mQuery);
        }

        v8.put(arg13);
        android.support.design.a.onEvent(arg12, v8.jo);
    }

    private void a(Article article, boolean arg14) {
        ArticleDetail v6 = null;
        long v10 = 0;
        if (article != null) {
            if (!arg14) {
                this.mVideoAutoPlayHelperDetail.b(this.context);
            }
            long v0 = this.f;
            if ((this.af) && (this.ae)) {
                if (this.ab == null) {
                    this.ab = new Stack();
                }

                this.ab.push(this.mArticle);
                if (this.ad == null) {
                    this.ad = new Stack();
                }
                this.ad.push(new Pair(Integer.valueOf(this.k), Integer.valueOf(this.l)));
            }

            this.d(article);
            this.c(article);
            this.mArticleDetail = v6;
            this.aa = true;
            this.O = this.f;
            this.f = this.mArticle.groupId;
            this.M = this.mArticle.itemId;
            this.N = this.mArticle.aggrType;
            this.bh = true;
            this.aj = false;
            this.al = false;
            this.aq = v10;
            this.ar = v10;
            this.as = false;
            this.at = false;
            this.av = false;
            this.aw = false;
            this.r = false;
            this.s = false;
            this.B = false;
            if (this.aV != null) {
                if (!this.ae) {
                    this.aV.clear();
                } else if (!this.af) {
                    this.aV.remove(Long.valueOf(v0));
                }
            }

            if (this.aW != null) {
                this.aW.clear();
            }

            if (this.mNewVideoFragmentHelper != null) {
                mNewVideoFragmentHelper.n = false;
                mNewVideoFragmentHelper.o = false;
                mNewVideoFragmentHelper.p = false;
                mNewVideoFragmentHelper.q = false;
                mNewVideoFragmentHelper.r = false;
                mNewVideoFragmentHelper.t = false;
                mNewVideoFragmentHelper.u = false;
                mNewVideoFragmentHelper.l = false;
                mNewVideoFragmentHelper.m = false;
                if (this.mNewVideoFragmentHelper.mVideoDetailExtraHolder != null) {
                    VideoDetailExtraHolder videoDetailExtraHolder = this.mNewVideoFragmentHelper.mVideoDetailExtraHolder;
                    videoDetailExtraHolder.M = false;
                    videoDetailExtraHolder.a(false);
                    if (videoDetailExtraHolder.mCoverImage != null) {
                        Log.d("travis", "NewVideoDetailFragment:::setImageBitmap(null)");
                        videoDetailExtraHolder.mCoverImage.setImageBitmap(null);
                    }
                }

                if (this.mNewVideoFragmentHelper.e != null) {
                    this.mNewVideoFragmentHelper.e.a(null);
                }
            }
            this.a(4, this.mNewVideoFragmentHelper);
            this.d(this.mNewVideoFragmentHelper);
            this.d = v10;
            if (article.ao != null && article.ao.adId > v10) {
                this.d = article.ao.adId;
            }

            if (this.aX != null) {
                this.aX.ad_id = this.d;
            }

            if (this.mNewVideoFragmentHelper != null && this.mNewVideoFragmentHelper.mNewDetailAdapter != null) {
                this.mNewVideoFragmentHelper.mNewDetailAdapter.mAdId = v10;
            }

            this.bundleDownloadAppLogExtra = this.d > v10 ? article.aG : "";
            this.x();
            if (this.mVideoAutoPlayHelperDetail != null) {
                this.mVideoAutoPlayHelperDetail.g.clear();
                this.mVideoAutoPlayHelperDetail.a(this.mArticle, this.ba);
                this.mVideoAutoPlayHelperDetail.a(arg14);
            }

            this.F = v10;
            this.b = ((BaseArticle) null);
            this.G = v10;
            this.an = this.ba == 1 ? "click_album" : "click_related";
            boolean v0_3 = AppData.getInstance().getAbSettings().isAppLogOld();
            if (this.d > v10) {
                this.a(new BaseArticle(this.f, this.M, this.N), this.d, v0_3);
            } else if (arg14) {
                this.a("go_detail_auto", new BaseArticle(this.f, this.M, this.N), v10, this.K());
            } else {
                this.a(new BaseArticle(this.f, this.M, this.N), v10, v0_3);
            }

            this.ba = 0;
            this.u();
        }
    }

    private void a(BaseArticle arg9, long arg10, boolean arg12) {
        if (arg12) {
            if (AppData.getInstance().getAbSettings().isAppLogOld()) {
                this.a("go_detail", arg9, arg10, this.K());
            }

            if (!AppData.getInstance().getAbSettings().isAppLogNew()) {
                return;
            }

            try {
                this.K().put("ad_id", arg10);
                this.K().put("log_pb", this.mLogPb);
            } catch (JSONException v0) {
            }

            this.a("go_detail", this.K(), arg9);
        }
    }

    private void a(String arg10, BaseArticle arg11, long arg12, JSONObject arg14) {
        JSONObject v8;
        long v4 = 0;
        String v3 = this.J();
        if (!android.support.design.a.isTextEmpty(arg10)) {
            long v6 = arg11 != null ? arg11.itemId : v4;
            int v0 = arg11 != null ? arg11.aggrType : 0;
            if (arg14 == null) {
                v8 = new JSONObject();
            } else {
                v8 = arg14;
            }

            try {
                if (!v8.has("item_id")) {
                    v8.put("item_id", v6);
                }

                if (v8.has("aggr_type")) {

                } else {
                    v8.put("aggr_type", v0);
                }
            } catch (Exception v0_1) {
            }


            Context v1 = this.getContext();
            if (arg11 != null) {
                v4 = arg11.groupId;
            }

            MobClickCombiner.onEvent(v1, arg10, v3, v4, arg12, v8);
        }
    }

    private void checkConnectAndPlay(String arg19, int arg20, int arg21) {
        this.aF = arg19;
        this.aG = arg20;
        this.aH = arg21;
        if (!NetworkUtils.isNetworkAvailable(this.context)) {
            this.showImageToast(com.ss.android.article.browser.R.drawable.close_popup_textpage, com.ss.android.article.browser.R.string.net_unvailable);
            this.ax.obtainMessage(16, 4, 0).sendToTarget();
        } else if (NetworkUtils.isWifi(this.context) || AppData.getInstance().userAllowUseMobileNet) {
            this.startPlayVideo();
        } else {
            final Context context = this.context;
            this.ax.obtainMessage(16, 4, 0).sendToTarget();
            AlertDialog.Builder builder = com.ss.android.j.b.createDialogBuilder(context);
            final long v8 = this.d;
            final long v6 = this.mArticle == null ? 0 : this.mArticle.groupId;
            builder.setMessage(com.ss.android.article.browser.R.string.video_mobile_play_dlg_content);
            builder.setPositiveButton(com.ss.android.article.browser.R.string.video_mobile_play,
                    new DialogInterface.OnClickListener() {

                        public final void onClick(DialogInterface dialogInterface, int which) {
                            NewVideoDetailFragment.this.mAppData.userAllowUseMobileNet = true;
                            NewVideoDetailFragment.this.startPlayVideo();
                            MobClickCombiner.onEvent(context, "video", "net_alert_confirm", v6, v8);
                        }
                    });
            builder.setNegativeButton(com.ss.android.article.browser.R.string.video_mobile_stop,
                    new DialogInterface.OnClickListener() {

                        public final void onClick(DialogInterface arg9, int arg10) {
                            MobClickCombiner.onEvent(context, "video", "net_alert_cancel", v6, v8);
                        }
                    });
            MobClickCombiner.onEvent(context, "video", "net_alert_show", v6, v8);
            builder.setCancelable(false);
            builder.show();
        }
    }

    private void a(String arg8, BaseArticle arg9, long arg10) {
        this.a(arg8, arg9, arg10, null);
    }

    private void a(boolean arg11, int arg12, boolean arg13, boolean arg14) {
        if (!this.isHostActivityDead()) {
            NewVideoFragmentHelper v9 = this.mNewVideoFragmentHelper;
            if (v9 != null) {
                int v0 = v9.mListView.getHeaderViewsCount();
                Article v1 = this.mArticle;
                if (v1 != null && (v1.disableScrollOver()) && (arg13)) {
                    arg12 = 2;
                }

                switch (arg12) {
                    case 4: {
                        v0 = 2;
                        break;
                    }
                }

                int v8 = v9.mListView.getFirstVisiblePosition() <= 0 || v9.mListView.getLastVisiblePosition() < v0 || arg12 != 4 ? v0 : 0;
                boolean v1_1 = v8 > 0 ? true : false;
                if (v1_1) {
                    this.E = false;
                } else {
                    this.E = true;
                    CallbackCenter.notifyCallback(IVideoController.RESHOW_END_COVER, new Object[0]);
                }

                ((NewDetailActivity) this.getActivity()).h(v1_1);
                if (arg14) {
                    if (v1_1) {
                        MobClickCombiner.onEvent(this.context, "xiangping", "video_detail_enter_comment", this.mArticle.groupId, 0);
                    } else {
                        MobClickCombiner.onEvent(this.context, "xiangping", "video_detail_enter_backtop", this.mArticle.groupId, 0);
                    }
                }

                if (v8 > 0) {
                    this.B = true;
                }

                if (v9.mListView != null) {
                    v9.mListView.setSelection(v8);
                    this.k = v9.mListView.getFirstVisiblePosition();
                    if (v9.mListView.getChildAt(0) != null) {
                        this.l = v9.mListView.getChildAt(0).getTop();
                    }
                }

                if (v9.mNewDetailAdapter.h) {
                    v9.mNewDetailAdapter.h = false;
                }

                if (arg11) {
                    this.a("handle_open_drawer");
                    return;
                }

                this.G();
            }
        }
    }

    final CommentTabCache a(long arg6,
                            NewVideoFragmentHelper arg8) {
        CommentTabCache v0_1;
        v0_1 = (CommentTabCache) this.aW.get(Long.valueOf(arg6));
        if (v0_1 == null) {
            v0_1 = arg8.mCommentTabCache;
            if (v0_1 == null || arg6 != v0_1.itemId) {
                v0_1 = new CommentTabCache(arg6);
            }

            this.aW.put(Long.valueOf(arg6), v0_1);
        }

        if (arg8.mCommentTabCache != v0_1) {
            arg8.mCommentTabCache = v0_1;
        }

        return v0_1;
    }

    public final void a() {
        Article v1 = this.mArticle;
        if (v1 != null) {
            String v0 = v1.userRepin ? "unfavorite_button" : "favorite_button";
            this.a(v0, ((BaseArticle) v1));
        }
    }

    protected final void a(String arg10, BaseArticle arg11) {
        long v6 = 0;
        if (arg11 != null && arg11.groupId > v6) {
            JSONObject v8 = new JSONObject();
            try {
                v8.put("item_id", arg11.itemId);
                v8.put("aggr_type", arg11.aggrType);
            } catch (JSONException v0) {
            }

            MobClickCombiner.onEvent(this.getContext(), "detail", arg10, arg11.groupId, v6, v8);
        }
    }

    final void a(int arg5) {
        if (arg5 < NewVideoDetailFragment.D) {
            if (!this.E) {
                this.E = true;
            }
        } else if (this.E) {
            this.E = false;
        }

        if ((this.ac) && !this.E && !this.mVideoController.isFullScreen()) {
            VideoAutoPlayHelperDetail v0 = this.mVideoAutoPlayHelperDetail;
            IVideoController v1 = this.mVideoController;
            if (v1 != null && !v0.d) {
                v0.d = true;
                v1.stopAutoPlayAnimation();
            }
        }
    }

    public final void a(Comment comment) {
        if (!this.isHostActivityDead()) {
            NewVideoFragmentHelper v3 = this.mNewVideoFragmentHelper;
            if (v3 != null) {
                Article v4 = this.mArticle;
                if (v4 != null && comment != null) {
                    boolean v0 = v4.groupId != comment.groupId || v4.itemId != comment.itemId ? false : true;
                    if (!v0) {
                        v0 = v4.getItemKey().equals(comment.itemKey);
                    }

                    if (!v0) {
                        return;
                    }

                    if (android.support.design.a.isTextEmpty(comment.text)) {
                        return;
                    }

                    CommentTabCache v0_1 = this.a(this.f, this.mNewVideoFragmentHelper);
                    ArticleTabComment v5 = v0_1.mArticleTabComments[0];
                    v5.commentWrapperList.add(0, CommentWrapper.fromComment(comment));
                    if (v5.totalNumber >= 0) {
                        ++v5.totalNumber;
                    }

                    ArticleTabComment v6 = v0_1.mArticleTabComments[1];
                    v6.commentWrapperList.add(0, CommentWrapper.fromComment(comment));
                    if (v6.totalNumber >= 0) {
                        ++v6.totalNumber;
                    }

                    ++v4.commentCount;
                    if (v3.mCommentTabCache == v0_1) {
                        v3.e.a(false);
                        v3.mNewDetailAdapter.addAllComment(v5.commentWrapperList);
                        v3.mNewDetailAdapter.notifyDataSetChanged();
                        this.c(v4);
                    }

                    this.a(true, 2, true, false);
                }
            }
        }
    }

    final void showBrowserFragment(final VideoExtendLink videoExtendLink) {
        if (this.mBrowserFragment == null) {
            if (this.x == null) {
                this.x = LayoutInflater.from(this.getContext()).inflate(com.ss.android.article.browser.R.layout.jl, this.mNewVideoFragmentHelper.mContentLayout, false);
                this.mNewVideoFragmentHelper.mContentLayout.addView(this.x);
                View v0 = this.x.findViewById(com.ss.android.article.browser.R.id.adv);
                View v3 = this.x.findViewById(com.ss.android.article.browser.R.id.adw);
                ((TextView) v0).setText(videoExtendLink.wapTitle);
                v3.setOnClickListener(new View.OnClickListener() {

                    public final void onClick(View view) {
                        NewVideoDetailFragment.this.n();
                        NewVideoDetailFragment.this.a("close", videoExtendLink.id);
                    }
                });
            }

            this.mBrowserFragment = new BrowserFragment();
            this.mBrowserFragment.O = false;
            Bundle bundle = new Bundle();
            bundle.putString("bundle_download_app_log_extra", this.bundleDownloadAppLogExtra);
            bundle.putLong("ad_id", videoExtendLink.id);
            bundle.putString("bundle_url", videoExtendLink.url);
            bundle.putBoolean("show_toolbar", false);
            bundle.putBoolean("bundle_user_webview_title", false);
            this.mBrowserFragment.setArguments(bundle);
            try {
                this.getChildFragmentManager().beginTransaction().replace(com.ss.android.article.browser.R.id.adx, this.mBrowserFragment).commitAllowingStateLoss();
            } catch (Throwable throwable) {
                throwable.printStackTrace();
            }
        }

        this.x.setTag(videoExtendLink);
        this.x.setVisibility(View.VISIBLE);
        this.m();
        if (this.bc == null) {
            this.bc = new TranslateAnimation(0, 0f, 0, 0f, 1, 1f, 1, 0f);
            this.bc.setDuration(300);
        }

        this.x.startAnimation(this.bc);
        if (this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.L != null && this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.L.b != null) {
            final RelativeLayout relativeLayout = this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.L.b;
            if (relativeLayout.getHeight() != ((ViewGroup.MarginLayoutParams) this.x.getLayoutParams()).topMargin) {
                ViewGroup.LayoutParams v0_3 = this.x.getLayoutParams();
                ((ViewGroup.MarginLayoutParams) v0_3).topMargin = ((View) relativeLayout).getHeight();
                this.x.setLayoutParams(v0_3);
            }
            ((View) relativeLayout).getViewTreeObserver().addOnGlobalLayoutListener(
                    new ViewTreeObserver.OnGlobalLayoutListener() {

                        public final void onGlobalLayout() {
                            if (relativeLayout.getHeight() != ((ViewGroup.MarginLayoutParams) NewVideoDetailFragment.this.x.getLayoutParams()).topMargin) {
                                ViewGroup.LayoutParams v0 = NewVideoDetailFragment.this.x.getLayoutParams();
                                ((ViewGroup.MarginLayoutParams) v0).topMargin = relativeLayout.getHeight();
                                NewVideoDetailFragment.this.x.setLayoutParams(v0);
                            }
                        }
                    });
        }
        this.a("detail_show", videoExtendLink.id);
    }

    final void a(String event, long arg12) {
        JSONObject jsonObject = new JSONObject();
        try {
            jsonObject.put("is_ad_event", 1);
            if (!TextUtils.isEmpty(this.bundleDownloadAppLogExtra)) {
                jsonObject.put("log_extra", this.bundleDownloadAppLogExtra);
            }
        } catch (JSONException jsonException) {
        }
        Context context = this.getContext();
        MobClickCombiner.onEvent(context, "detail_landingpage", event, arg12, this.mArticle != null ? this.mArticle.groupId : 0, jsonObject);
    }

    public final void onCommentLoaded(CommentFetcher commentFetcher, boolean arg14) {
        if (!this.isHostActivityDead()
                && commentFetcher != null
                && commentFetcher.article != null
                && commentFetcher.a == this.mNewVideoFragmentHelper.mCommentTabCache.mArticleTabComments[commentFetcher.tabIndex].counter) {
            int v0 = commentFetcher.tabIndex != 0 || (this.q()) ? 0 : 1;
            long v2 = commentFetcher.article.groupId;
            long v4 = commentFetcher.article.itemId;
            if (Logger.debug()) {
                Logger.d("DetailActivity", "onCommentLoaded " + v2 + " "
                        + commentFetcher.tabIndex + " " + commentFetcher.offset + " " + arg14);
            }

            NewVideoFragmentHelper newVideoFragmentHelper = this.mNewVideoFragmentHelper;
            newVideoFragmentHelper.mCommentTabCache.load[commentFetcher.tabIndex] = false;
            if (!arg14) {
                if (newVideoFragmentHelper == null) {
                    return;
                }

                if (v0 == 0) {
                    return;
                }

                if (commentFetcher.errorCode == 12) {
                    this.M();
                    return;
                }

                newVideoFragmentHelper.mFooter.switchToError(com.ss.android.article.browser.R.string.ss_error_unknown);
                return;
            }

            ArticleTabComment articleTabComment = this.mNewVideoFragmentHelper.mCommentTabCache.mArticleTabComments[commentFetcher.tabIndex];
            if (articleTabComment.h <= 0) {
                articleTabComment.h = System.currentTimeMillis();
            }

            articleTabComment.copyAllComment(commentFetcher.articleTabComment);
            a(articleTabComment.commentWrapperList);
            articleTabComment.offset += commentFetcher.j;
            if (articleTabComment.commentWrapperList.isEmpty()) {
                articleTabComment.hasMore = false;
            }

            int v1 = articleTabComment.commentWrapperList.size() == 0 ? 1 : 0;
            if (v1 == 0) {
                if (v0 == 0) {
                } else if ((articleTabComment.detailNoComment) && !newVideoFragmentHelper.l) {
                    newVideoFragmentHelper.mFooter.setViewMoreText(com.ss.android.article.browser.R.string.label_click_to_view_comments);
                    newVideoFragmentHelper.mFooter.switchToMoreContent();
                } else {

                    newVideoFragmentHelper.mFooter.setViewMoreText(com.ss.android.article.browser.R.string.ss_load_more);
                    if (articleTabComment.hasMore) {
                        newVideoFragmentHelper.mFooter.switchToMoreContent();
                    } else {

                        newVideoFragmentHelper.mFooter.hideFooterContent();
                    }
                }
            } else if (v0 != 0) {
                newVideoFragmentHelper.mFooter.hideFooterContent();
                v1 = (articleTabComment.banComment) || (commentFetcher.article.mBanComment) ? 1 : 0;
                com.ss.android.article.base.feature.detail2.video.a.l v8 = newVideoFragmentHelper.e;
                boolean v1_1 = v1 == 0 ? true : false;
                v8.a(v1_1);
            }

            if (v0 != 0) {
                v1 = 0;
                if (!articleTabComment.detailNoComment || (newVideoFragmentHelper.l)) {
                    newVideoFragmentHelper.mNewDetailAdapter.addAllComment(articleTabComment.commentWrapperList);
                    if (commentFetcher.topCommentId > 0) {
                        v1 = 1;
                    }
                } else {
                    newVideoFragmentHelper.mNewDetailAdapter.addAllComment((List) null);
                }

                newVideoFragmentHelper.mNewDetailAdapter.i = articleTabComment.goTopicDetail;
                newVideoFragmentHelper.mNewDetailAdapter.notifyDataSetChanged();
                if (v1 == 0) {
                } else {
                    v1 = newVideoFragmentHelper.mListView.getHeaderViewsCount();
                    if (newVideoFragmentHelper.mListView == null) {
                    } else {
                        newVideoFragmentHelper.mListView.setSelection(v1);
                        this.k = newVideoFragmentHelper.mListView.getFirstVisiblePosition();
                        if (newVideoFragmentHelper.mListView.getChildAt(0) != null) {
                            this.l = newVideoFragmentHelper.mListView.getChildAt(0).getTop();
                        }

                        this.a(Math.abs(this.l));
                    }
                }
            }

            if (articleTabComment.totalNumber >= 0 && commentFetcher.article != null) {
                if (articleTabComment.totalNumber < articleTabComment.commentWrapperList.size()) {
                    articleTabComment.totalNumber = articleTabComment.commentWrapperList.size();
                }

                if (commentFetcher.article.commentCount == articleTabComment.totalNumber) {
                } else {
                    commentFetcher.article.commentCount = articleTabComment.totalNumber;
                    DBHelper.getInstance(this.context).a(v2, v4, articleTabComment.totalNumber);
                    NewVideoFragmentHelper v1_2 = this.mNewVideoFragmentHelper;
                    Article v2_1 = this.mArticle;
                    if (v1_2 == null) {
                    } else if (v2_1 == null) {
                    } else if (v2_1 != commentFetcher.article) {
                    } else {
                        if (articleTabComment.banComment) {
                            commentFetcher.article.mBanComment = true;
                        }
                        if (v0 == 0) {
                        } else {
                            this.c(v2_1);
                        }
                    }
                }
            }

            label_175:
            if (v0 != 0 && (this.al)) {
                this.al = false;
                if (!android.support.design.a.isTextEmpty(this.bb)) {
                    MobClickCombiner.onEvent(this.getContext(), "enter_comment", this.bb);
                }

                this.a(true, 4, true, false);
            }

            if (!this.am) {
                return;
            }

            this.am = false;
            this.H();
        }
    }

    final void a(NewVideoFragmentHelper arg8) {
        if (arg8 != null && arg8.e != null && !arg8.o) {
            Article v2 = this.mArticle;
            if (v2 != null && (this.B)) {
                int[] v3 = new int[2];
                int v0 = 0;
                if (this.A != null) {
                    v0 = this.A[1];
                }

                int v1 = 2147483647;
                v3[1] = v1;
                if (arg8.e.F != null && (arg8.e.F.isShown())) {
                    arg8.e.F.getLocationInWindow(v3);
                    v1 = v3[1] + arg8.e.F.getHeight();
                }

                if (v1 >= v0) {
                    return;
                }

                arg8.o = true;
                this.a("enter_comment", ((BaseArticle) v2), this.d);
                if (!this.mAppData.loginCommentFirst) {
                    this.a(this.context, 1);
                }

                this.aY = true;
            }
        }
    }

    public final void onArticleInfoLoaded(Article article, ArticleInfo articleInfo) {
        if (!this.isHostActivityDead() && article != null && article == this.mArticle) {
            if (articleInfo == null) {
                long itemId = article.groupId;
                if (Logger.debug()) {
                    UIUtils.showImageToast(this.context,
                            com.ss.android.article.browser.R.drawable.close_popup_textpage,
                            "load info failed: " + itemId);
                }

                MobClickCombiner.onEvent(this.context, "video_detail", "related_video_stat", 1, 0);
            } else {
                if (Logger.debug()) {
                    Logger.d("DetailActivity", "onArticleInfoLoaded " + articleInfo.itemId);
                }

                if (!this.ae || (this.af) || !this.aV.containsKey(Long.valueOf(articleInfo.itemId))) {
                    this.aV.put(Long.valueOf(articleInfo.itemId), articleInfo);
                }

                if (!this.ae || (this.af)) {
                    this.P = articleInfo.landingPageUrl;
                    this.mThirdVideoPartnerData = articleInfo.mThirdVideoPartnerData;
                    this.mArticle.videoWatchCount = articleInfo.videoWatchCount;
                }
                this.a(this.mArticle, mNewVideoFragmentHelper, this.mArticleDetail);
                int v0_1 = 0;
                if (articleInfo.diggCount < 0 || article.diggCount == articleInfo.diggCount) {
                    articleInfo.diggCount = -1;
                } else {
                    article.diggCount = articleInfo.diggCount;
                    v0_1 = 1;
                }

                if (articleInfo.buryCount < 0 || article.buryCount == articleInfo.buryCount) {
                    articleInfo.buryCount = -1;
                } else {
                    article.buryCount = articleInfo.buryCount;
                    v0_1 = 1;
                }

                if (articleInfo.videoWatchCount < 0 || article.videoWatchCount >= articleInfo.videoWatchCount) {
                    articleInfo.videoWatchCount = -1;
                } else {
                    article.videoWatchCount = articleInfo.videoWatchCount;
                    v0_1 = 1;
                }

                if (articleInfo.userDigg) {
                    if ((article.userDigg) || (article.userBury)) {
                        articleInfo.userDigg = false;
                    } else {
                        article.userDigg = true;
                        v0_1 = 1;
                    }

                    articleInfo.userBury = false;
                } else {
                    if (!articleInfo.userBury) {
                    } else if (!article.userDigg && !article.userBury) {
                        article.userBury = true;
                        v0_1 = 1;
                    } else {
                        articleInfo.userBury = false;
                    }
                }

                if ((android.support.design.a.isTextEmpty(articleInfo.shareUrl)) || (articleInfo.shareUrl.equals(article.shareUrl))) {
                    articleInfo.shareUrl = null;
                } else {
                    article.shareUrl = articleInfo.shareUrl;
                    v0_1 = 1;
                }

                if ((android.support.design.a.isTextEmpty(articleInfo.displayUrl)) || (articleInfo.displayUrl.equals(article.displayUrl))) {
                    articleInfo.displayUrl = null;
                } else {
                    article.displayUrl = articleInfo.displayUrl;
                    v0_1 = 1;
                }

                if ((android.support.design.a.isTextEmpty(articleInfo.displayTitle)) || (articleInfo.displayTitle.equals(article.displayTitle))) {
                    articleInfo.displayTitle = null;
                } else {
                    article.displayTitle = articleInfo.displayTitle;
                    v0_1 = 1;
                }

                if (articleInfo.delete) {
                    article.delete = true;
                    article.commentCount = 0;
                }

                if ((articleInfo.banComment) && !article.mBanComment) {
                    article.mBanComment = true;
                    v0_1 = 1;
                }

                if (v0_1 != 0 && !articleInfo.delete) {
                    DBHelper.getInstance(this.context).updateArticleInfo(articleInfo);
                }

                if (this.mArticle == article) {
                    this.c(article);
                }

                if (mNewVideoFragmentHelper != null && this.mArticle == article) {
                    if (article.delete) {
                        if (!this.isHostActivityDead()) {
                            ((NewDetailActivity) this.getActivity()).switchToArticleDeleted(article);
                        } else {
                        }

                        return;
                    } else {
                        if (mNewVideoFragmentHelper.e.q != null && mNewVideoFragmentHelper.e.q.getChildCount() != 0) {
                            mNewVideoFragmentHelper.e.q.removeAllViews();
                        }

                        mNewVideoFragmentHelper.e.a(articleInfo);
                        VideoDetailExtraHolder videoDetailExtraHolder = mNewVideoFragmentHelper.mVideoDetailExtraHolder;
                        ArticleInfo articleInfo1 = mNewVideoFragmentHelper.e != null ? mNewVideoFragmentHelper.e.H : null;
                        if (videoDetailExtraHolder.mArticle != null && videoDetailExtraHolder.mArticle.getUserId() > 0) {
                            videoDetailExtraHolder.d = videoDetailExtraHolder.mArticle.getUserId();
                        }

                        MediaInfo mediaInfo = articleInfo1 != null ? articleInfo1.mMediaInfo : null;
                        videoDetailExtraHolder.f = mediaInfo;
                        if (videoDetailExtraHolder.f != null) {
                            videoDetailExtraHolder.mPGCNameTv.setText(videoDetailExtraHolder.f.name);
                            videoDetailExtraHolder.mAvatarLoader.loadAvatar(videoDetailExtraHolder.mPGCAvatarIv, videoDetailExtraHolder.f.avatarUrl);
                            if (videoDetailExtraHolder.f.userVerified) {
                                videoDetailExtraHolder.mPGCNameTv.setPadding(0, 0, 0, 0);
                                UIUtils.setVisibility(videoDetailExtraHolder.mPGCVerifiedImage, 0);
                            } else {
                                UIUtils.setVisibility(videoDetailExtraHolder.mPGCVerifiedImage, 8);
                            }
                        }

                        videoDetailExtraHolder.a();
                        if (articleInfo1 != null && articleInfo1.mThirdVideoPartnerData != null) {
                            ThirdVideoPartnerData v0_3 = articleInfo1.mThirdVideoPartnerData;
                            if (v0_3 != null && !TextUtils.isEmpty(v0_3.packageName) && !TextUtils.isEmpty(v0_3.androidOpenUrl) && !TextUtils.isEmpty(v0_3.androidDownloadUrl) && !videoDetailExtraHolder.g) {
                                UIUtils.setVisibility(videoDetailExtraHolder.mPGCInfoLayout, 0);
                                videoDetailExtraHolder.mPGCAvatarIv.setVisibility(View.GONE);
                                videoDetailExtraHolder.mPGCNameTv.setVisibility(View.GONE);
                                videoDetailExtraHolder.mSubscribeBtn.setVisibility(View.GONE);
                                videoDetailExtraHolder.mSubscribeStatus.setVisibility(View.GONE);
                                videoDetailExtraHolder.mProgressBar.setVisibility(View.GONE);
                                RelativeLayout.LayoutParams v1_1 = new RelativeLayout.LayoutParams(-2, -2);
                                v1_1.addRule(3, com.ss.android.article.browser.R.id.pgc_info_top_divider);
                                videoDetailExtraHolder.mPGCInfoLayout.setLayoutParams(((ViewGroup.LayoutParams) v1_1));
                                v1_1 = new RelativeLayout.LayoutParams(-1, videoDetailExtraHolder.mContext.getResources().getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.dj));
                                v1_1.setMargins(0, videoDetailExtraHolder.mContext.getResources().getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.dl), 0, videoDetailExtraHolder.mContext.getResources().getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.dk));
                                videoDetailExtraHolder.mThirdPartnerImageView.setLayoutParams(((ViewGroup.LayoutParams) v1_1));
                                if (ToolUtils.isAppInstalled(videoDetailExtraHolder.mContext, v0_3.packageName)) {
                                    if (videoDetailExtraHolder.K != null) {
                                        videoDetailExtraHolder.K.a("subscribe_show_jump");
                                    }

                                    videoDetailExtraHolder.mThirdPartnerImageView.setUrl(v0_3.belowBannerOpenImgUrl);
                                } else {
                                    if (videoDetailExtraHolder.K != null) {
                                        videoDetailExtraHolder.K.a("subscribe_show_download");
                                    }

                                    videoDetailExtraHolder.mThirdPartnerImageView.setUrl(v0_3.belowBannerDownloadImgUrl);
                                }

                                videoDetailExtraHolder.mThirdPartnerImageView.setVisibility(View.VISIBLE);
                            }
                        }

                        if (article.videoSubjectId <= 0) {
                        } else if (this.ak) {
                        } else {
                            mNewVideoFragmentHelper.e.a();
                            this.ak = true;
                        }
                    }
                }

                this.mNewVideoFragmentHelper.mNewDetailAdapter.mArticle = this.mArticle;
                if (!android.support.design.a.isTextEmpty(this.P) && this.getVideoController() != null) {
                    this.getVideoController().showAdGoLanding(this.P);
                }

                if (this.mThirdVideoPartnerData != null && !TextUtils.isEmpty(this.mThirdVideoPartnerData.androidOpenUrl)
                        && !TextUtils.isEmpty(this.mThirdVideoPartnerData.androidDownloadUrl)
                        && !TextUtils.isEmpty(this.mThirdVideoPartnerData.packageName)
                        && this.getVideoController() != null) {
                    this.getVideoController().showThirdPartnerGuide(this.mThirdVideoPartnerData, this.mThirdPartnerListner);
                }

                String v0_4 = articleInfo.videoLabelHtml;
                if (this.mNewVideoFragmentHelper.mVideoDetailExtraHolder != null) {
                    if (this.mArticleDetail != null && !android.support.design.a.isTextEmpty(this.mArticleDetail.content)) {
                        v0_4 = this.mArticleDetail.content + v0_4;
                    }

                    if (this.mArticle.publishTime > 0) {
                        String v1_2 = new SimpleDateFormat(this.context.getString(com.ss.android.article.browser.R.string.video_publish_prefix)).format(new Date(this.mArticle.publishTime * 1000));
                        v0_4 = android.support.design.a.isTextEmpty(v0_4) ? v1_2 : v1_2 + v0_4;
                    }

                    VideoDetailExtraHolder videoDetailExtraHolder = this.mNewVideoFragmentHelper.mVideoDetailExtraHolder;
                    if (!TextUtils.isEmpty(v0_4)) {
                        videoDetailExtraHolder.a(videoDetailExtraHolder.mVideoContentTv, v0_4);
                        UIUtils.setVisibility(videoDetailExtraHolder.mExpandBtn, 0);
                        UIUtils.setLayoutMargins(videoDetailExtraHolder.mVideoTitleTv, -3, -3, 0, -3);
                    }

                    if (articleInfo.adVideoInfo != null) {
                        if (!android.support.design.a.isTextEmpty(this.mArticle.source)) {
                            articleInfo.adVideoInfo.e = this.mArticle.source;
                        } else if (!android.support.design.a.isTextEmpty(this.mArticle.mediaName)) {
                            articleInfo.adVideoInfo.e = this.mArticle.mediaName;
                        }

                        if (this.mArticle.aF != null) {
                            if (((this.mArticle.aF instanceof FeedDownloadAppAd)) && ("web".equals(((FeedDownloadAppAd) this.mArticle.aF).type))) {
                            } else {
                                this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.a(this.mArticle.aF, articleInfo.adVideoInfo);
                            }
                        } else if (articleInfo.feedDownloadAppAd == null) {
                        } else {
                            if (android.support.design.a.isTextEmpty(articleInfo.feedDownloadAppAd.logExtra)) {
                                articleInfo.feedDownloadAppAd.logExtra = this.bundleDownloadAppLogExtra;
                            }

                            articleInfo.feedDownloadAppAd.id = this.d;
                            if ("web".equals(articleInfo.feedDownloadAppAd.type)) {
                            } else {
                                this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.a(articleInfo.feedDownloadAppAd, articleInfo.adVideoInfo);
                            }
                        }
                    } else if (this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.L == null) {
                    } else {
                        this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.L.a(null, null);
                    }
                }

                if (this.ad != null && this.ab != null && (this.ae)) {
                    this.ad.size();
                    this.ab.size();
                }

                final VideoExtendLink videoExtendLink = articleInfo.videoExtendLink;
                if (videoExtendLink != null && !TextUtils.isEmpty(videoExtendLink.url)) {
                    this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.mVideoExtendLinkText.setVisibility(View.VISIBLE);
                    if (AppData.getInstance().getAbSettings().isVideoFragmentShare()) {
                        this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.shareLayout.setVisibility(View.GONE);
                    }

                    this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.mVideoExtendLinkText.setText(videoExtendLink.name);
                    this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.mVideoExtendLinkText.setOnClickListener(new View.OnClickListener() {

                        public final void onClick(View view) {
                            if (videoExtendLink.openNewPage) {
                                Intent intent = new Intent(NewVideoDetailFragment.this.context, VideoExtendLinkActivity.class);
                                intent.putExtra("arg_log_extra", NewVideoDetailFragment.this.bundleDownloadAppLogExtra);
                                intent.putExtra("arg_video_extend_link", videoExtendLink);
                                NewVideoDetailFragment.this.context.startActivity(intent);
                            } else {
                                NewVideoDetailFragment.this.showBrowserFragment(videoExtendLink);
                            }

                            if (NewVideoDetailFragment.this.mAppData.getAbSettings().isAppLogOld()) {
                                NewVideoDetailFragment.this.a("click_landingpage", videoExtendLink.id);
                            }

                            if (NewVideoDetailFragment.this.mAppData.getAbSettings().isAppLogNew()) {
                                NewVideoDetailFragment.a(NewVideoDetailFragment.this, "detail_click_landingpage");
                            }
                        }
                    });
                    if (!videoExtendLink.openDirect) {
                        return;
                    }

                    if (videoExtendLink.openNewPage) {
                        Intent intent = new Intent(this.context, VideoExtendLinkActivity.class);
                        intent.putExtra("arg_log_extra", this.bundleDownloadAppLogExtra);
                        intent.putExtra("arg_video_extend_link", ((Parcelable) videoExtendLink));
                        this.context.startActivity(intent);
                        return;
                    } else {
                        this.showBrowserFragment(videoExtendLink);
                        return;
                    }
                }

                if (AppData.getInstance().getAbSettings().isVideoFragmentShare()) {
                    UIUtils.setVisibility(this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.shareLayout, View.VISIBLE);
                    if (!ToolUtils.isAppInstalled(this.context, "com.tencent.mobileqq")) {
                        UIUtils.setVisibility(this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.ivQQ, View.GONE);
                    }
                }

            }
        }
    }

    public final void onArticleDetailLoadedWithCache(Article article, ArticleDetail articleDetail) {
    }

    public final void onLoaded(Article article, AbsArticle absArticle, ArticleDetail articleDetail) {
        if (!this.isHostActivityDead()) {
            if (articleDetail != null && (articleDetail.delete)) {
                if (!this.isHostActivityDead()) {
                    ((NewDetailActivity) this.getActivity()).switchToArticleDeleted(this.mArticle);
                } else {
                }

                return;
            }

            int v0 = articleDetail == null || (TextUtils.isEmpty(articleDetail.content)) ? 0 : 1;
            if (v0 == 0 && (NetworkUtils.isNetworkAvailable(this.context))) {
                this.aX.loadArticleDetail(absArticle.getItemKey(), article, absArticle);
                return;
            }

            this.onArticleDetailLoadedFromInternet(articleDetail);
        }
    }

    public final void a(IVideoFullscreen videoFullscreen) {
        if (videoFullscreen != null) {
            this.mVideoFullscreen = videoFullscreen;
        }
    }

    final void a(BaseAdsData baseAdsData) {
        if (baseAdsData != null && baseAdsData.isValid() && baseAdsData.K) {
            BaseAdsData.trackAdShow(this.context, "detail_ad", baseAdsData, 1);
        }
    }

    public final void onLoaded(String arg1, long arg2, Response response) {
    }

    public final void onArticleDetailLoadedFromInternet(String arg2, Article article, ArticleDetail articleDetail) {
        if (!this.isHostActivityDead()) {
            this.onArticleDetailLoadedFromInternet(articleDetail);
        }
    }

    public final void shareToWeChat(String arg1, JSONObject arg2) {
    }

    public final void a(boolean arg9) {
        long v6 = 0;
        this.c = arg9;
        if (arg9) {
            this.H = System.currentTimeMillis();
        } else {
            long v4 = this.H != v6 ? System.currentTimeMillis() - this.H : v6;
            MobClickCombiner.onEvent(this.context, "stay_category", "video_album", v4, v6);
        }
    }

    public final boolean a(CommentWrapper arg2) {
        return this.aZ.contains(arg2);
    }

    public final boolean a(Article article) {
        return this.a(article, 0);
    }

    public final boolean a(Article article, int arg4) {
        if (article == null || !android.support.design.a.hasVideo(article)) {
            return false;
        } else {
            this.ba = arg4;
            this.ax.obtainMessage(15, article).sendToTarget();
            return true;
        }
    }

    public final void b(String arg10) {
        if (this.mThirdVideoPartnerData != null && !TextUtils.isEmpty(this.mThirdVideoPartnerData.androidOpenUrl)
                && !TextUtils.isEmpty(this.mThirdVideoPartnerData.androidDownloadUrl) && !TextUtils.isEmpty(this.mThirdVideoPartnerData.packageName)) {
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put("app_value", this.mThirdVideoPartnerData.packageName);
            } catch (JSONException jsonException) {
            }
            MobClickCombiner.onEvent(this.getContext(), "video_banner", arg10, this.f, 0, jsonObject);
        }
    }

    private View findViewById(int id) {
        return this.mVideoDetailLayout.findViewById(id);
    }

    public final void onNoData() {
        this.a(1, this.mNewVideoFragmentHelper);
    }

    public final void b(Comment comment) {
        if (this.isViewValid() && comment != null) {
            this.aU = comment;
            if (this.mNewVideoFragmentHelper != null && this.mArticle != null) {
                Comment v0 = this.aU;
                if (v0 != null && this.mArticle.groupId == v0.groupId) {
                    MobClickCombiner.onEvent(this.getContext(), "comment", "click_comment");
                    MobClickCombiner.onEvent(this.getContext(), "comment", "repost_menu");
                    if (this.mDetailHelper != null) {
                        this.mDetailHelper.b();
                        this.mDetailHelper.a(v0.a(this.m), v0.commentId, false);
                    }
                    return;
                }
                this.aU = null;
            }
        }
    }

    public final void addComment(CommentWrapper commentWrapper) {
        this.aZ.add(commentWrapper);
    }

    final void b(NewVideoFragmentHelper arg12) {
        JSONObject v8;
        int v0_1;
        if (arg12 != null && arg12.e != null && arg12.e.H != null && !arg12.e.H.relatedVideoToutiaoList.isEmpty() && (!arg12.q || !arg12.r || !arg12.s)) {
            int[] v0 = new int[2];
            if (arg12.e.q == null) {
                return;
            }

            arg12.e.q.getLocationInWindow(v0);
            int[] v1 = new int[]{v0[1], v0[1] + arg12.e.q.getHeight()};
            v0 = this.A;
            if (v0 == null || v0.length != 2) {
                v0_1 = 0;
            } else {
                if (v1[0] < v1[1] && v0[0] < v0[1] && v1[0] < v0[1] && v0[0] < v1[1]) {
                    v0_1 = 1;
                } else {
                    v0_1 = 0;
                }
            }

            if (v0_1 == 0) {
                return;
            }

            int v10;
            for (v10 = 0; v10 < arg12.e.q.getChildCount(); ++v10) {
                if (v10 >= arg12.e.H.relatedVideoToutiaoList.size()) {
                    return;
                }

                Object v0_2 = arg12.e.H.relatedVideoToutiaoList.get(v10);
                View v1_1 = arg12.e.q.getChildAt(v10);
                int[] v2 = new int[2];
                v1_1.getLocationOnScreen(v2);
                if ((((float) v2[1])) >= (((float) this.aM)) - UIUtils.dp2px(this.context, 45f)) {
                    return;
                }

                long v4 = 0;
                if (((RelatedVideoTouTiao) v0_2).article != null && ((RelatedVideoTouTiao) v0_2).article.ao != null && ((RelatedVideoTouTiao) v0_2).article.ao.adId > 0) {
                    v4 = ((RelatedVideoTouTiao) v0_2).article.ao.adId;
                }

                if (((RelatedVideoTouTiao) v0_2).a == 2 && !arg12.s) {
                    v8 = new JSONObject();
                    if (!android.support.design.a.isTextEmpty(((RelatedVideoTouTiao) v0_2).logExtra)) {
                        try {
                            v8.put("log_extra", ((RelatedVideoTouTiao) v0_2).logExtra);
                        } catch (JSONException v1_2) {
                            v1_2.printStackTrace();
                        }
                    } else {
                        try {
                            v8.put("log_extra", "{}");
                        } catch (JSONException v1_2) {
                            v1_2.printStackTrace();
                        }
                    }

                    MobClickCombiner.onEvent(this.context, "embeded_ad", "show", v4, 0, v8);
                    arg12.s = true;
                }

                if (((RelatedVideoTouTiao) v0_2).a == 1 && !arg12.r && !this.c) {
                    v8 = null;
                    if (((RelatedVideoTouTiao) v0_2).videoAlbumInfo.videoSubject > 0) {
                        v8 = new JSONObject();
                        try {
                            v8.put("video_subject_id", ((RelatedVideoTouTiao) v0_2).videoAlbumInfo.videoSubject);
                        } catch (JSONException v1_2) {
                        }
                    }

                    MobClickCombiner.onEvent(this.context, "video", "detail_album_show", ((RelatedVideoTouTiao) v0_2).videoAlbumInfo.mediaId, 0, v8);
                    arg12.r = true;
                    if (((RelatedVideoTouTiao) v0_2).videoAlbumInfo == null) {
                    } else {
                        ((RelatedVideoTouTiao) v0_2).videoAlbumInfo.j = this;
                    }
                }

                if (((RelatedVideoTouTiao) v0_2).a == 0 && !arg12.q) {
                    MobClickCombiner.onEvent(this.context, "detail", "related_video_show", this.f, 0);
                    arg12.q = true;
                }

                if (((RelatedVideoTouTiao) v0_2).a == 3 && !((RelatedVideoTouTiao) v0_2).g) {
                    if (((RelatedVideoTouTiao) v0_2).baseAdsData != null) {
                        try {
                            v8 = new JSONObject();
                            v8.put("is_ad_event", 1);
                            v8.put("log_extra", ((RelatedVideoTouTiao) v0_2).baseAdsData.logExtra);
                            MobAdClickCombiner.onAdEvent(this.context, "detail_ad_list", "show", ((RelatedVideoTouTiao) v0_2).baseAdsData.id, 0, v8, 1);
                        } catch (JSONException v1_2) {
                        }

                        AppUtil.a(((RelatedVideoTouTiao) v0_2).baseAdsData.trackUrlList, this.context);
                    }

                    ((RelatedVideoTouTiao) v0_2).g = true;
                }
            }
        }
    }

    public final void b(Article article) {
        this.ba = 0;
        this.a(article, true);
    }

    public final void shareToQQ(String arg1, JSONObject arg2) {
    }

    public final void onVideoCompletion(boolean arg1) {
        this.ac = arg1;
    }

    final void c(Article article) {
        if (article != null) {
            switch (this.getCommentMode()) {
                case 0: {
                    if (!this.isHostActivityDead()) {
                        ((NewDetailActivity) this.getActivity()).setFavorIconSelected(article.userRepin);
                    }
                    break;
                }
            }
            int commentCount = article.commentCount;
            boolean allowComment = !article.mBanComment;
            if (this.isHostActivityDead()) {
                return;
            }
            ((NewDetailActivity) this.getActivity()).setCommentCount(commentCount);
            ((NewDetailActivity) this.getActivity()).setWriteCommentEnabled(allowComment);
        }
    }

    private void initVideoCoverLayout(NewVideoFragmentHelper newVideoFragmentHelper) {
        if (newVideoFragmentHelper.mVideoDetailExtraHolder.mVideoCoverLayout == null && this.mLayoutInflater != null && this.mTopVideoHolder != null) {
            View videoCoverLayout = this.mLayoutInflater.inflate(com.ss.android.article.browser.R.layout.video_detail_cover_layout, this.mTopVideoHolder, false);
            this.mTopVideoHolder.addView(videoCoverLayout, new FrameLayout.LayoutParams(-1, -2));
            VideoDetailExtraHolder videoDetailExtraHolder = newVideoFragmentHelper.mVideoDetailExtraHolder;
            videoDetailExtraHolder.mVideoCoverLayout = videoCoverLayout;
            videoDetailExtraHolder.mCoverTitle = videoCoverLayout.findViewById(com.ss.android.article.browser.R.id.cover_title);
            videoDetailExtraHolder.mCoverPlayIcon = videoCoverLayout.findViewById(com.ss.android.article.browser.R.id.cover_play_icon);
            videoDetailExtraHolder.mCoverDuration = videoCoverLayout.findViewById(com.ss.android.article.browser.R.id.cover_duration);
            videoDetailExtraHolder.mCoverSource = videoCoverLayout.findViewById(com.ss.android.article.browser.R.id.cover_source);
            videoDetailExtraHolder.mCoverImage = videoCoverLayout.findViewById(com.ss.android.article.browser.R.id.cover_image);
            videoDetailExtraHolder.mCoverBack = videoCoverLayout.findViewById(com.ss.android.article.browser.R.id.cover_back);
            videoCoverLayout.setVisibility(View.GONE);
        }
    }

    public final Article c() {
        Article v0_1;
        Article v2 = null;
        NewVideoFragmentHelper v0 = this.mNewVideoFragmentHelper;
        if (NetworkUtils.getNetworkType(this.context) != NetworkType.WIFI) {
            v0_1 = v2;
        } else {
            if (this.mVideoAutoPlayHelperDetail != null && AppData.getInstance().getAbSettings().getVideoAutoPlayCount() == this.mVideoAutoPlayHelperDetail.c + 1) {
                return v2;
            }

            if (v0 != null && v0.e != null && v0.e.H != null && !v0.e.H.relatedVideoToutiaoList.isEmpty()) {
                List v3 = v0.e.H.relatedVideoToutiaoList;
                for (int v1 = 0; v1 < v3.size(); ++v1) {
                    Object v0_2 = v3.get(v1);
                    if (((RelatedVideoTouTiao) v0_2).a == 0 && (((RelatedVideoTouTiao) v0_2).article == null || ((RelatedVideoTouTiao) v0_2).article.ao == null || ((RelatedVideoTouTiao) v0_2).article.ao.adId <= 0) && (this.mVideoAutoPlayHelperDetail.f == null || ((RelatedVideoTouTiao) v0_2).article == null || !this.mVideoAutoPlayHelperDetail.f.contains(Long.valueOf(((RelatedVideoTouTiao) v0_2).article.groupId)))) {
                        v0_1 = ((RelatedVideoTouTiao) v0_2).article;
                        if (v0_1 != null) {
                            return v0_1;
                        }
                        this.mVideoAutoPlayHelperDetail.b(this.context);
                        return v0_1;
                    }
                }
                this.mVideoAutoPlayHelperDetail.a(this.context);
                return v2;
            }
            this.mVideoAutoPlayHelperDetail.a(this.context);
            this.mVideoAutoPlayHelperDetail.b(this.context);
            v0_1 = v2;
        }

        return v0_1;
    }

    public final void onSharePlatformClick(int platform) {
        if (platform >= 0) {
            this.mArticleShareHelper.position = "detail_bottom_bar_out";
            this.mArticleShareHelper.share(platform, this.mArticle);
        }
    }

    public final void deleteComment(final Comment comment) {
        if (comment != null) {
            VideoAutoPlayHelperDetail.a(this.getVideoController());
            if (UpdateItemMgr.getInstance(this.getContext()).checkLoginAndNet(comment.userId)) {
                UpdateItemMgr.showDeleteConfirmDialog(this.getContext(), new DialogInterface.OnClickListener() {

                    public final void onClick(DialogInterface dialogInterface, int which) {
                        if (comment != null) {
                            NewVideoFragmentHelper newVideoFragmentHelper = NewVideoDetailFragment.this.mNewVideoFragmentHelper;
                            if (newVideoFragmentHelper != null && newVideoFragmentHelper.mCommentTabCache != null) {
                                if (newVideoFragmentHelper.mCommentTabCache.removeCommnet(comment.commentId)) {
                                    newVideoFragmentHelper.mNewDetailAdapter.addAllComment(newVideoFragmentHelper.mCommentTabCache.mArticleTabComments[0].commentWrapperList);
                                    newVideoFragmentHelper.mNewDetailAdapter.notifyDataSetChanged();
                                    --NewVideoDetailFragment.this.mArticle.commentCount;
                                    NewVideoDetailFragment.this.c(NewVideoDetailFragment.this.mArticle);
                                    NewVideoDetailFragment.this.a(NewVideoDetailFragment.this.mNewVideoFragmentHelper, NewVideoDetailFragment.this.mNewVideoFragmentHelper.mCommentTabCache);
                                }
                                UpdateItemMgr.getInstance(getContext()).deleteComment(comment.commentId);
                            }
                        }
                    }
                });
            }
        }
    }

    public final void shareToMoment(String arg1, JSONObject jsonObject) {
    }

    public final void onFullscreenChanged(boolean arg4) {
        this.bs = arg4;
        FragmentActivity activity = this.getActivity();
        if (activity != null) {
            boolean v1 = !arg4;
            ((NewDetailActivity) activity).setDetailToolBarVisible(v1);
        }
        this.y = false;
    }

    final boolean isHostActivityDead() {
        FragmentActivity fragmentActivity = this.getActivity();
        return fragmentActivity == null || ((NewDetailActivity) fragmentActivity).isFinishing();
    }

    private void d(Article article) {
        this.mArticle = article;
        if (this.mArticle != null && this.mArticle.groupId > 0) {
            this.mAppData.a(this.mArticle);
        }
    }

    private void d(NewVideoFragmentHelper arg5) {
        if (arg5 != null) {
            if (arg5.mNewDetailAdapter != null) {
                arg5.mNewDetailAdapter.onPause();
                arg5.mNewDetailAdapter.onDestroy();
            }

            arg5.mNewDetailAdapter = new NewDetailAdapter(this.context, ((Fragment) this), this.mDiggAnimationView);
            arg5.mNewDetailAdapter.mArticle = this.mArticle;
            arg5.mNewDetailAdapter.a(arg5.mListView);
            arg5.mNewDetailAdapter.j = ((com.ss.android.article.base.feature.detail.presenter.a) this);
            arg5.mNewDetailAdapter.mAdId = this.d;
            arg5.mListView.setAdapter(arg5.mNewDetailAdapter);
            arg5.mListView.setRecyclerListener(arg5.mNewDetailAdapter);
        }
    }

    final void d(boolean arg7) {
        Article v1 = this.mArticle;
        if (this.mArticleShareHelper != null && v1 != null) {
            if (arg7) {
                ArticleInfo v0 = null;
                if (this.mNewVideoFragmentHelper != null && this.mNewVideoFragmentHelper.e != null) {
                    v0 = this.mNewVideoFragmentHelper.e.H;
                }

                switch (this.getCommentMode()) {
                    case 1:
                    case 2: {
                        this.mArticleShareHelper.mCategoryName = this.R;
                        this.mArticleShareHelper.c(v1, v0, this.d);
                        return;
                    }
                }

                if (!v1.m() && !v1.n()) {
                    this.mArticleShareHelper.b(v1, v0, this.d);
                    return;
                }

                this.mArticleShareHelper.a(v1, v0, this.d);
            } else {
                this.mArticleShareHelper.mCategoryName = this.R;
                this.mArticleShareHelper.a(v1, this.d, true);
            }
        }
    }

    public final void d(String arg2, JSONObject arg3) {
        if (this.mArticleShareHelper != null) {
            this.mArticleShareHelper.position = arg2;
            this.mArticleShareHelper.fillShareParams(arg3);
        }
    }

    public final void e(final boolean arg7) {
        if (this.mThirdVideoPartnerData != null && !TextUtils.isEmpty(this.mThirdVideoPartnerData.androidOpenUrl) && !TextUtils.isEmpty(this.mThirdVideoPartnerData.androidDownloadUrl) && !TextUtils.isEmpty(this.mThirdVideoPartnerData.packageName)) {
            if (ToolUtils.isAppInstalled(this.getContext(), this.mThirdVideoPartnerData.packageName)) {
                String v0 = arg7 ? "player_click_jump" : "subscribe_click_jump";
                this.b(v0);
                AdsAppActivity.openUrl(this.getContext(), this.mThirdVideoPartnerData.androidOpenUrl, this.mThirdVideoPartnerData.packageName);
            } else {
                PermissionsManager.getInstance().requestPermission((Activity) this.context, new String[]{"android.permission.WRITE_EXTERNAL_STORAGE"},
                        new PermissionsResultAction() {
                            private final JSONObject b = new JSONObject();

                            public final void onGranted() {
                                String v0 = arg7 ? "player_click_download" : "subscribe_click_download";
                                NewVideoDetailFragment.this.b(v0);
                                if (NewVideoDetailFragment.this.mThirdVideoPartnerData != null) {
                                    AppUtil.a(NewVideoDetailFragment.this.mThirdVideoPartnerData.androidDownloadUrl,
                                            NewVideoDetailFragment.this.mThirdVideoPartnerData.packageName,
                                            NewVideoDetailFragment.this.context,
                                            this.b);
                                }
                            }

                            public final void onDenied(String arg1) {
                            }
                        });
            }
        }
    }

    public final AbsArticle getArticle() {
        return this.mArticle;
    }

    public final long getArticleId() {
        return this.d;
    }

    public final IVideoController getVideoController() {
        if (this.mVideoController == null && this.mTopVideoHolder != null) {
            if (VideoControllerSupplierProxy.getInstance().getVideoControllerInstance().isPauseFromList()) {
                this.mVideoController = VideoControllerSupplierProxy.getInstance().getVideoControllerInstance();
                VideoControllerSupplierProxy.getInstance().getVideoControllerInstance()
                        .reset(this.getContext(), this.mTopVideoHolder, false,
                                EnumSet.of(CtrlFlag.hideCloseBtn, CtrlFlag.alwayShowBackBtn, CtrlFlag.alwayShowMediaView, CtrlFlag.fixedSize));
            } else {
                this.mVideoController = VideoControllerSupplierProxy.getInstance()
                        .createVideoController(this.getContext(), this.mTopVideoHolder,
                                false,
                                EnumSet.of(CtrlFlag.hideCloseBtn, CtrlFlag.alwayShowBackBtn, CtrlFlag.alwayShowMediaView, CtrlFlag.fixedSize));
            }

            this.mVideoController.setOnCloseListener(this.mCloseListener);
            this.mVideoController.setFullScreenListener(this.bn);
        }

        DetailPageListener detailPageListener = this.mVideoController.getDetailPageListener();
        if (detailPageListener == null || detailPageListener != this) {
            this.mVideoController.setDetailPageListener(this);
        }

        return this.mVideoController;
    }

    public final int getCommentMode() {
        return mArticle == null ? 0 : mArticle.getCommentMode();
    }

    public final void onBack() {
        Object v0;
        if (this.x != null && this.x.getVisibility() == View.VISIBLE) {
            if (this.mBrowserFragment != null && (this.mBrowserFragment.q())) {
                return;
            }

            this.n();
            this.x.setVisibility(View.GONE);
            v0 = this.x.getTag();
            if (v0 != null) {
                this.a("close", ((VideoExtendLink) v0).id);
                this.x.setTag(null);
            }

            if (!this.y) {
                return;
            }
            this.y = false;
            ((NewDetailActivity) this.getActivity()).setDetailToolBarVisible(true);
            return;
        }

        try {
            JSONObject jsonObject = new JSONObject();
            if (this.ab != null && !this.ab.empty() && (this.ae)) {
                v0 = this.ab.pop();
                this.af = false;
                jsonObject.put("enter_from", this.getEnterFrom());
                jsonObject.put("back_position", "detail");
                MobClickCombiner.onEvent(this.context, "detail", "page_close_key", this.f, 0, jsonObject);
                this.a(((Article) v0), false);
                return;
            }

            if (this.ae) {
                this.an = this.ag;
            }

            jsonObject.put("enter_from", this.getEnterFrom());
            jsonObject.put("back_position", "list");
            MobClickCombiner.onEvent(this.context, "detail", "page_close_key", this.f, 0, jsonObject);
            this.p();
        } catch (JSONException v0_1) {
            v0_1.printStackTrace();
        }
    }

    public final void handleMsg(Message message) {
        boolean v1 = false;
        if ((this.isViewValid()) && (this.mDetailHelper == null || !this.mDetailHelper.handleMsg(message))) {
            AppData.isNightMode();
            switch (message.what) {
                case 15:
                    this.af = true;
                    this.a((Article) message.obj, false);
                    return;
                case 16:
                    if (message.arg1 == 0) {
                        return;
                    }
                    this.a(message.arg1, this.mNewVideoFragmentHelper);
                    return;
                case 1003:
                    v1 = true;
                    if (!(message.obj instanceof CommentFetcher)) {
                        return;
                    }
                    this.onCommentLoaded((CommentFetcher) message.obj, v1);
                    return;
                case 1004:
                    if (!(message.obj instanceof CommentFetcher)) {
                        return;
                    }
                    this.onCommentLoaded((CommentFetcher) message.obj, v1);
                case 10001:
                    this.showImageToast(com.ss.android.article.browser.R.drawable.doneicon_popup_textpage, com.ss.android.article.browser.R.string.toast_report_ok);
                    return;
                case 10002:
                    this.showImageToast(com.ss.android.article.browser.R.drawable.close_popup_textpage, com.ss.android.article.browser.R.string.toast_report_fail);
                    return;
            }
            return;
        }
    }

    public final int i() {
        int v0 = 0;
        if (this.mVideoController != null && (this.mVideoController.isVideoVisible())) {
            v0 = this.mVideoController.getPct();
        }

        return v0;
    }

    public final void initVideoView() {
    }

    public final boolean isStreamTab() {
        return false;
    }

    public final long j() {
        long v0 = this.F < 0 ? -1 : System.currentTimeMillis() - this.F;
        return v0;
    }

    public final int k() {
        return this.mNewVideoFragmentHelper == null
                || this.mNewVideoFragmentHelper.mVideoDetailExtraHolder == null
                || this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.mVideoCoverLayout == null
                ? 0
                : this.mNewVideoFragmentHelper.mVideoDetailExtraHolder.mVideoCoverLayout.getHeight();
    }

    public final void disableOverlaySwipe() {
        if (this.mSwipeOverlayFrameLayout != null) {
            this.mSwipeOverlayFrameLayout.setSwipeEnabled(false);
        }
    }

    final void m() {
        if ((this.x != null
                && this.x.getVisibility() == View.VISIBLE
                || (this.bs))
                && ((NewDetailActivity) this.getActivity()).mDetailToolBar.getVisibility() == View.VISIBLE) {
            this.y = true;
            ((NewDetailActivity) this.getActivity()).setDetailToolBarVisible(false);
        }
    }

    final void n() {
        if (this.x != null && this.x.getVisibility() == View.VISIBLE) {
            this.x.setVisibility(View.GONE);
            if (this.bd == null) {
                this.bd = new TranslateAnimation(0, 0f, 0, 0f, 1, 0f, 1, 1f);
                this.bd.setDuration(300);
                this.bd.setAnimationListener(new com.ss.android.article.base.ui.f() {

                    public final void onAnimationEnd(Animation arg3) {
                        super.onAnimationEnd(arg3);
                        if (NewVideoDetailFragment.this.y) {
                            NewVideoDetailFragment.this.y = false;
                            ((NewDetailActivity) NewVideoDetailFragment.this.getActivity()).setDetailToolBarVisible(true);
                        }

                        if (NewVideoDetailFragment.this.mBrowserFragment != null) {
                            try {
                                NewVideoDetailFragment.this.getChildFragmentManager().beginTransaction().remove(NewVideoDetailFragment.this.mBrowserFragment).commitAllowingStateLoss();
                            } catch (Throwable v0) {
                                v0.printStackTrace();
                            }

                            NewVideoDetailFragment.this.mBrowserFragment = null;
                        }
                    }
                });
            }
            this.x.startAnimation(this.bd);
        }
    }

    final void o() {
        if (!this.z) {
            this.ax.removeCallbacks(this.be);
            this.ax.post(this.be);
        }
    }

    public final void onActivityResult(int requestCode, int resultCode, Intent data) {
        if (com.ss.android.account.o.isRepeatBindError(requestCode, resultCode, data)) {
            this.av = true;
        } else if (requestCode == 1003) {
            this.mDetailHelper.c();
        } else {
            super.onActivityResult(requestCode, resultCode, data);
            if (100 == requestCode && -1 == resultCode && data != null) {
                long v0 = data.getLongExtra("comment_id", 0);
                if (this.mNewVideoFragmentHelper != null && (this.mNewVideoFragmentHelper.mCommentTabCache.removeCommnet(v0))) {
                    this.mNewVideoFragmentHelper.mNewDetailAdapter.addAllComment(this.mNewVideoFragmentHelper.mCommentTabCache.mArticleTabComments[0].commentWrapperList);
                    this.mNewVideoFragmentHelper.mNewDetailAdapter.notifyDataSetChanged();
                    --this.mArticle.commentCount;
                    this.c(this.mArticle);
                    this.a(this.mNewVideoFragmentHelper, this.mNewVideoFragmentHelper.mCommentTabCache);
                }
            }
        }
    }

    @Nullable
    public final View onCreateView(LayoutInflater layoutInflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
        this.E = true;
        this.mVideoAutoPlayHelperDetail = VideoAutoPlayHelperDetail.getInstance();
        View videoDetailLayout = layoutInflater.inflate(com.ss.android.article.browser.R.layout.video_detail_fragment, container, false);
        this.mVideoDetailLayout = (ViewGroup) videoDetailLayout;
        return videoDetailLayout;
    }

    public final void onDestroy() {
        VideoPref.removeLastVideoIdAndPos();
        Iterator v1 = this.bq.entrySet().iterator();
        while (v1.hasNext()) {
        }

        if (this.mVideoAutoPlayHelperDetail != null) {
            IVideoController videoController = this.mVideoController;
            if (videoController != null) {
                VideoAutoPlayHelperDetail.a(videoController);
            }
        }

        CallbackCenter.removeCallback(BaseAppData.callbackTypeAddArticleCommentFromUpdate, this.aK);
        CallbackCenter.removeCallback(BaseAppData.callbackTypeVideoSubOrUnsub, this.aL);
        this.mAppData.b(this.mArticle);
        if (this.mNetworkStatusMonitor != null) {
            this.mNetworkStatusMonitor.onDestroy();
        }

        if (this.ay != null) {
            this.ay.onDestroy();
        }

        if (this.az != null) {
            this.az.onDestroy();
        }

        if (this.aC != null) {
            this.aC.a = true;
        }

        VideoControllerSupplierProxy.getInstance().getVideoControllerInstance().clearOnCloseListener();
        if (mNewVideoFragmentHelper != null) {
            mNewVideoFragmentHelper.mNewDetailAdapter.onDestroy();
        }

        if (this.aX != null) {
            this.aX.onDestroy();
        }

        if (this.aT != null) {
            this.aT.onDestroy();
        }

        if (this.aS != null) {
            this.aS.onDestroy();
        }

        if (this.mImageLoader != null) {
            this.mImageLoader.onDestroy();
        }

        if (this.aY) {
            this.mAppData.loginCommentFirst = false;
        }
        this.ax.removeCallbacksAndMessages(null);
        ActivityStackManager.removeActivity(Type.DETAIL_ACTIVITY, this.getActivity());
        super.onDestroy();
        if (this.mVideoController != null) {
            this.mVideoController.unRegisterReceiver();
        }
    }

    public final void onPause() {
        CallbackCenter.notifyCallback(IVideoController.STOP_END_COVER, new Object[0]);
        VideoAutoPlayHelperDetail.a(this.getVideoController());
        if (this.mVideoController != null && (this.mVideoController.isVideoVisible())) {
            if (this.mVideoController.isVideoPlaying()) {
                this.bk = true;
            }

            this.a(2, this.mNewVideoFragmentHelper);
        }

        if (mNewVideoFragmentHelper != null
                && mArticle != null
                && (mNewVideoFragmentHelper.m)
                && this.b != null
                && mArticle.groupId == this.b.groupId) {
            this.x();
        }

        this.F = 0L;
        this.b = null;
        this.G = 0L;
        this.mAppData.d(false);
        if (mNewVideoFragmentHelper != null) {
            mNewVideoFragmentHelper.mNewDetailAdapter.onPause();
        }
        super.onPause();
        mAppData.exitVideoDetailCount = System.currentTimeMillis() - mAppData.lastClickVideoTabTime > (long) (mAppData.videoTabBubbleInterval * 24 * 60 * 60 * 1000) ? 1 : 0;
        SharedPreferences.Editor editor = mAppData.mContext.getSharedPreferences("app_setting", 0).edit();
        editor.putInt("exit_video_detail_count", mAppData.exitVideoDetailCount);
        SharedPreferenceCompat.commit(editor);
    }

    public final void onResume() {
        String v3 = null;
        long v6 = 0;
        if (this.mNetworkStatusMonitor != null) {
            this.mNetworkStatusMonitor.registerNetworkStateReceiver();
        }

        if (mNewVideoFragmentHelper != null) {
            if (!this.ai && mNewVideoFragmentHelper.e != null) {
                com.ss.android.article.base.feature.detail2.video.a.l v1 = mNewVideoFragmentHelper.e;
                if (v1.H != null && v1.H.aa != null) {
                    if (v1.H.mDownloadAppAd != null && (v1.H.mDownloadAppAd.isValid()) && v1.v != null) {
                        v1.v.b();
                    }

                    if (v1.z != null) {
                        v1.z.b();
                    }

                    if (v1.y != null) {
                        v1.y.b();
                    }

                    if (v1.A != null) {
                        v1.A.b();
                    }
                }
            }

            if (this.ai) {
            } else if (mNewVideoFragmentHelper.mVideoDetailExtraHolder == null) {
            } else if (mNewVideoFragmentHelper.mVideoDetailExtraHolder.L == null) {
            } else {
                com.ss.android.article.base.feature.detail2.video.a.a v1_1 = mNewVideoFragmentHelper.mVideoDetailExtraHolder.L;
                if (v1_1.g == null) {
                } else if (!"app".equals(v1_1.h.type)) {
                } else {
                    v1_1.g.e();
                }
            }
        }

        super.onResume();
        if (this.ai) {
            this.ai = false;
            if (this.au) {
                JSONObject v8 = new JSONObject();
                try {
                    v8.put("item_id", this.M);
                    v8.put("aggr_type", this.N);
                } catch (Exception v1_2) {
                }

                this.getContext();
                AppLog.onEvent("apn", "notice", v3, this.f, v6, v8);
            }

            this.u();
        }

        if (this.getVideoController() != null) {
            IVideoController videoController = this.getVideoController();
            videoController.setPlayCompleteListener(this.mPlayCompleteListener);
            videoController.setShareListener(this.mShareListener);
        }

        if (this.isActive()) {
            boolean v1_4 = AppData.isNightMode();
            if (v1_4 != this.S) {
                if (this.mNoNetView != null) {
                    this.mNoNetView.initNoDataActionBtn();
                }

                if (this.mNewVideoFragmentHelper != null) {
                    this.mNewVideoFragmentHelper.mDetailErrorView.mNoNetView.initNoDataActionBtn();
                }

                this.S = v1_4;
                this.mDetailHelper.notifyViewAdaptNightMode();
                this.mVideoDetailLayout.setBackgroundResource(com.ss.android.article.browser.R.color.c);
                NewVideoFragmentHelper v2 = this.mNewVideoFragmentHelper;
                if (v2 == null) {
                } else {
                    this.a(v2, v1_4);
                    this.I();
                    v2.mNewDetailAdapter.notifyDataSetChanged();
                }
            }
        }

        if (this.aX != null) {
            this.aX.onResume();
        }

        if (this.aT != null) {
            this.aT.onPause();
        }

        if (this.aS != null) {
            this.aS.onPause();
        }

        if (mNewVideoFragmentHelper != null) {
            mNewVideoFragmentHelper.mNewDetailAdapter.onResume();
        }

        if (this.mImageLoader != null) {
            this.mImageLoader.onPause();
        }

        Article v8_1 = this.mArticle;
        long v10 = this.d;
        if (v8_1 == null || mNewVideoFragmentHelper == null || !mNewVideoFragmentHelper.m) {
            this.F = v6;
            this.b = ((BaseArticle) null);
            this.G = v6;
        } else {
            this.F = System.currentTimeMillis();
            this.b = new BaseArticle(v8_1.groupId, v8_1.itemId, v8_1.aggrType);
            this.G = v10;
        }

        if (v8_1 != null) {
            this.c(v8_1);
        }

        if (this.av) {
            Spipe.loginDupAlert(this.getActivity());
        } else {
            SplashAdActivity.a(this.getContext(), this.aw);
            this.aw = false;
        }

        this.av = false;
        if (this.ay != null) {
            this.ay.onPause();
        }

        if (this.az != null) {
            this.az.onPause();
        }

        if (this.bk) {
            if ((this.ac) && this.mVideoController != null) {
                this.mVideoController.showNewCover(this.mArticle);
                return;
            }

            this.a(3, this.mNewVideoFragmentHelper);
        }
    }

    public final void onStop() {
        super.onStop();
        if (this.ay != null) {
            this.ay.onStop();
        }

        if (this.az != null) {
            this.az.onStop();
        }

        if (this.mNewVideoFragmentHelper != null && this.mNewVideoFragmentHelper.mNewDetailAdapter != null) {
            this.mNewVideoFragmentHelper.mNewDetailAdapter.onStop();
        }

        if (this.aX != null) {
            this.aX.onPause();
        }

        if (this.mImageLoader != null) {
            this.mImageLoader.onStop();
        }

        if (this.aT != null) {
            this.aT.onStop();
        }

        if (this.aS != null) {
            this.aS.onStop();
        }

        if (this.mNoNetView != null) {
            this.mNoNetView.b();
        }
    }

    public final void onViewCreated(View view, Bundle bundle) {
        super.onViewCreated(view, bundle);
        if (this.mMonitorFPS == null && (com.bytedance.article.common.a.g.a())) {
            this.mMonitorFPS = new MonitorFPS(this.getContext(), "detail_video");
        }

        this.mAppData = AppData.getInstance();
        CallbackCenter.addCallback(BaseAppData.callbackTypeAddArticleCommentFromUpdate, this.aK);
        CallbackCenter.addCallback(BaseAppData.callbackTypeVideoSubOrUnsub, this.aL);
        this.mNetworkStatusMonitor = new NetworkStatusMonitor(this.getContext());
        this.mArticleActionHelper = new ArticleActionHelper(this.getContext());
        this.context = this.getContext();
        this.U = this.context.getResources();
        this.m = Spipe.inst();
        this.S = AppData.isNightMode();
        this.ai = true;
        DBHelper.getInstance(this.getContext());
        this.ab = new Stack();
        this.mVideoAutoPlayHelperDetail = VideoAutoPlayHelperDetail.getInstance();
        this.ad = new Stack();
        this.ae = AppData.getInstance().getAbSettings().isVideoDetailRelatedBackStackEnabled();
        if (!this.w()) {
            this.getActivity().finish();
        } else {
            this.mDetailHelper = new DetailHelper(this.getActivity(), ItemType.ARTICLE, this.ax, this.mArticleActionHelper, "detail");
            Bundle bundle1 = this.getArguments();
            if (bundle1 != null && bundle1.getBoolean("from_notification", false)) {
                this.aw = true;
            }

            this.aM = this.U.getDisplayMetrics().heightPixels;
            this.aB = this.U.getDisplayMetrics().widthPixels -
                    this.U.getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.d7)
                    - this.U.getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.d8);
            this.mDetailHelper.a();
            new ShareHelper(this.getContext(), ((IComponent) this), this.mAppData);
            new TimeFormatter(this.getContext());
            AppData.isNightMode();
            this.mVideoDetailLayout.setBackgroundResource(com.ss.android.article.browser.R.color.activity_bg_color);
            this.mTopVideoHolder = (FrameLayout) this.findViewById(com.ss.android.article.browser.R.id.top_video_holder);
            this.mSwipeOverlayFrameLayout = (SwipeOverlayFrameLayout) this.findViewById(com.ss.android.article.browser.R.id.swipe_overlay);
            this.mSwipeOverlayFrameLayout.setVisibility(View.VISIBLE);
            this.mSwipeOverlayFrameLayout.setOnSwipeListener(new SwipeOverlayFrameLayout.OnSwipeBackListener() {

                public final boolean onSwipeBack() {
                    NewVideoDetailFragment.this.n = true;
                    try {
                        JSONObject jsonObject = new JSONObject();
                        jsonObject.put("enter_from", NewVideoDetailFragment.this.getEnterFrom());
                        MobClickCombiner.onEvent(NewVideoDetailFragment.this.context, "detail", "back_gesture", NewVideoDetailFragment.this.f, 0, jsonObject);
                    } catch (JSONException jsonException) {
                    }
                    NewVideoDetailFragment.this.p();
                    return true;
                }

                public final boolean b() {
                    return false;
                }
            });
            Resources resources = this.getResources();
            int v4 = resources.getDimensionPixelSize(com.ss.android.article.browser.R.dimen.detail_ad_banner_img_size);
            int v5 = resources.getDimensionPixelSize(com.ss.android.article.browser.R.dimen.d2);
            this.aC = new TaskInfo();
            this.mBaseImageManager = new BaseImageManager(this.getContext());
            this.ay = new AvatarLoader(com.ss.android.article.browser.R.drawable.detail_ad_banner_img_bg, this.aC, this.mBaseImageManager, v4, v5, false);
            v4 = resources.getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.detail_pgc_avatar_size);
            this.az = new AvatarLoader(com.ss.android.article.browser.R.drawable.feed_user, this.aC, this.mBaseImageManager, v4, v4, true);
            this.mImageLoader = new ImageLoader(this.getContext(), this.aC, 8, 2, this.mBaseImageManager, this.aB, 2000);
            int v0_1 = resources.getDimensionPixelSize(com.ss.android.article.browser.R.dimen.fb);
            int v1 = resources.getDimensionPixelSize(com.ss.android.article.browser.R.dimen.item_image_width);
            int v3 = resources.getDisplayMetrics().widthPixels;
            int v2 = resources.getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.item_image_total_padding);
            v4 = resources.getDimensionPixelOffset(com.ss.android.article.browser.R.dimen.f_);
            v2 = (v3 - v2) / 3;
            if (v2 >= v1) {
                v1 = v2;
            }

            if (v1 <= v0_1) {
                v0_1 = v1;
            }

            this.aO = v0_1;
            this.aP = this.aO * 9 / 16;
            this.aQ = v3 - v4;
            this.aR = this.aQ;
            this.aT = new ImageLoader(this.getContext(), this.aC, 16, 20, 2, this.mBaseImageManager, this.aO, this.aP);
            this.aS = new ImageLoader(this.getContext(), this.aC, 8, 2, this.mBaseImageManager, this.aQ, this.aR);
            this.mDiggAnimationView = com.ss.android.article.base.ui.DiggAnimationView.a(this.mVideoDetailLayout);
            Context v0_2 = this.getContext();
            this.mLayoutInflater = LayoutInflater.from(v0_2);
            v0_2.getResources().getDisplayMetrics();
            this.aV = new InfoLRUCache(8, 8);
            this.aW = new InfoLRUCache(8, 8);
            new ImageManager(this.context);
            this.aC = new TaskInfo();
            View detailPage = this.findViewById(com.ss.android.article.browser.R.id.detail_page);
            NewVideoFragmentHelper newVideoFragmentHelper = new NewVideoFragmentHelper();
            newVideoFragmentHelper.mContentLayout = detailPage.findViewById(com.ss.android.article.browser.R.id.content_layout);
            newVideoFragmentHelper.mListView = detailPage.findViewById(com.ss.android.article.browser.R.id.bottom_listview);
            if (Build.VERSION.SDK_INT < 21) {
                newVideoFragmentHelper.mListView.setOverScrollMode(2);
            }

            detailPage.findViewById(com.ss.android.article.browser.R.id.bottom_listview_layout);
            newVideoFragmentHelper.mDetailErrorView = detailPage.findViewById(com.ss.android.article.browser.R.id.detail_error_view);
            newVideoFragmentHelper.mDetailErrorView.setOnRetryClickListener(new View.OnClickListener() {

                public final void onClick(View arg2) {
                    NewVideoDetailFragment.this.u();
                }
            });
            newVideoFragmentHelper.mNightModeOverlay = detailPage.findViewById(com.ss.android.article.browser.R.id.night_mode_overlay);
            detailPage.setTag(newVideoFragmentHelper);
            WebViewTweaker.tryTweakWebCoreHandler(this.mAppData.mHackWebCoreHandler, this.mAppData.mHackWebCoreHandlerZTE, this.mAppData.mHackWebCoreHandlerAll);
            detailPage = this.mLayoutInflater.inflate(com.ss.android.article.browser.R.layout.ss_new_comment_footer, newVideoFragmentHelper.mListView, false);
            newVideoFragmentHelper.mFooter = new a$a(this, detailPage.findViewById(com.ss.android.article.browser.R.id.ss_footer_content));
            newVideoFragmentHelper.mFooter.hideFooterContent();
            newVideoFragmentHelper.mSSMore = detailPage.findViewById(com.ss.android.article.browser.R.id.ss_more);
            newVideoFragmentHelper.mListView.addFooterView(detailPage, null, false);
            View v4_1 = this.mLayoutInflater.inflate(com.ss.android.article.browser.R.layout.gj, newVideoFragmentHelper.mListView, false);
            View v5_1 = this.mLayoutInflater.inflate(com.ss.android.article.browser.R.layout.new_article_detail_info_second_header, newVideoFragmentHelper.mListView, false);
            newVideoFragmentHelper.e = new com.ss.android.article.base.feature.detail2.video.a.l(this.getActivity(), this.mNetworkStatusMonitor, this.mLayoutInflater, ((LinearLayout) v4_1), v5_1, this.mImageLoader, this.aT, this.aS, this.aO, this.aP, this.aQ, this.aR, this.aB);
            newVideoFragmentHelper.e.E.setOnClickListener(new View.OnClickListener() {

                public final void onClick(View arg6) {
                    if (NewVideoDetailFragment.this.mDetailHelper != null) {
                        NewVideoDetailFragment.this.mDetailHelper.a("", 0, true);
                    }
                }
            });
            if (newVideoFragmentHelper.mListView != null && this.mLayoutInflater != null && newVideoFragmentHelper.mVideoDetailExtraHolder == null) {
                View detailVideoContentLayout = this.mLayoutInflater.inflate(com.ss.android.article.browser.R.layout.detail_video_content_layout, newVideoFragmentHelper.mListView, false);
                newVideoFragmentHelper.mVideoDetailExtraHolder = new VideoDetailExtraHolder(this.getContext(), detailVideoContentLayout, this.aS, this.az, this.mArticleActionHelper, this.mDiggAnimationView);
                newVideoFragmentHelper.mListView.addHeaderView(detailVideoContentLayout, null, false);
                this.initVideoCoverLayout(newVideoFragmentHelper);
            }

            com.ss.android.article.base.feature.detail2.video.a.l v1_2 = newVideoFragmentHelper.e;
            if (v1_2.t != null && v1_2.p != null) {
                ViewParent v0_3 = v1_2.t.getParent();
                if (((v0_3 instanceof ViewGroup)) && ((ViewGroup) v0_3).indexOfChild(v1_2.u) < ((ViewGroup) v0_3).indexOfChild(v1_2.p)) {
                    ((ViewGroup) v0_3).removeView(v1_2.t);
                    ((ViewGroup) v0_3).addView(v1_2.t);
                }
            }

            newVideoFragmentHelper.mListView.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() {

                public final void onGlobalLayout() {
                    int v2 = 2;
                    if (NewVideoDetailFragment.this.mNewVideoFragmentHelper != null && NewVideoDetailFragment.this.mNewVideoFragmentHelper.mListView != null) {
                        if (NewVideoDetailFragment.this.A == null) {
                            NewVideoDetailFragment.this.A = new int[v2];
                        }

                        int[] v0 = new int[v2];
                        NewVideoDetailFragment.this.mNewVideoFragmentHelper.mListView.getLocationInWindow(v0);
                        NewVideoDetailFragment.this.A[0] = v0[1];
                        NewVideoDetailFragment.this.A[1] = v0[1] + NewVideoDetailFragment.this.mNewVideoFragmentHelper.mListView.getHeight();
                        if (NewVideoDetailFragment.this.A[0] >= NewVideoDetailFragment.this.A[1]) {
                            return;
                        }

                        NewVideoDetailFragment.this.mNewVideoFragmentHelper.mListView.getViewTreeObserver().removeGlobalOnLayoutListener(((ViewTreeObserver.OnGlobalLayoutListener) this));
                    }
                }
            });
            newVideoFragmentHelper.mListView.addHeaderView(v4_1, null, false);
            newVideoFragmentHelper.mListView.addHeaderView(v5_1, null, false);
            this.d(newVideoFragmentHelper);
            this.ax.postDelayed(new Runnable() {

                public final void run() {
                    if (NewVideoDetailFragment.this.getActivity() != null) {
                        ((NewDetailActivity) NewVideoDetailFragment.this.getActivity()).mDetailToolBar.h = true;
                        if (NewVideoDetailFragment.this.z) {
                            NewVideoDetailFragment.this.z = false;
                            NewVideoDetailFragment.this.o();
                        }
                    }
                }
            }, 2000);
            newVideoFragmentHelper.mListView.setOnScrollListener(new com.ss.android.article.base.feature.detail2.video.g(this));
            this.mNewVideoFragmentHelper = newVideoFragmentHelper;
            this.aX = new DetailLoader(this.R, "", this.d, this, 64);
            this.aX.article_page = 1;
            this.aX.useV16 = true;
            this.mArticleShareHelper = new ArticleShareHelper(this.getActivity(), this.mArticleActionHelper, this.mDetailHelper, 200);
            if (this.mVideoAutoPlayHelperDetail != null) {
                VideoAutoPlayHelperDetail v0_4 = this.mVideoAutoPlayHelperDetail;
                ArticleShareHelper v2_1 = this.mArticleShareHelper;
                if (v2_1 != null) {
                    v0_4.mArticleShareHelperRef = new WeakReference(v2_1);
                }
            }

            this.mArticleShareHelper.q = true;
            this.mArticleShareHelper.g = (new com.ss.android.article.share.e.b() {

                public final boolean a(com.ss.android.article.share.entity.a arg11, View arg12, com.ss.android.article.share.c.a arg13) {
                    boolean v1 = true;
                    boolean v9 = false;
                    if (arg11 == null) {
                        return v9;
                    }

                    switch (arg11.e) {
                        case 1: {
                            ((NewDetailActivity) NewVideoDetailFragment.this.getActivity()).saveShareWay(1);
                            return false;
                        }
                        case 2: {
                            ((NewDetailActivity) NewVideoDetailFragment.this.getActivity()).saveShareWay(2);
                            return false;
                        }
                        case 3:
                        case 4: {
                            label_96:
                            ((NewDetailActivity) NewVideoDetailFragment.this.getActivity()).saveShareWay(3);
                            return false;
                        }
                        case 12: {
                            NewVideoDetailFragment v4 = NewVideoDetailFragment.this;
                            String v3 = "pgc_button";
                            if (v4.mArticle == null) {
                                return false;
                            }

                            if (v4.mArticle.mediaInfo == null) {
                                return false;
                            }

                            JSONObject v8 = new JSONObject();
                            try {
                                v8.put("item_id", v4.mArticle.itemId);
                            } catch (Exception v0_3) {
                                v0_3.printStackTrace();
                            }

                            MobClickCombiner.onEvent(v4.context, "detail", v3, v4.mArticle.mediaInfo.id, 0, v8);
                            return false;
                        }
                        case 13: {
                            Article v2 = NewVideoDetailFragment.this.mArticle;
                            if (v2 == null) {
                                return v1;
                            }

                            NewVideoDetailFragment v3_1 = NewVideoDetailFragment.this;
                            String v0_2 = v2.userRepin ? "unfavorite_button" : "favorite_button";
                            v3_1.a(v0_2, ((BaseArticle) v2));
                            NewVideoDetailFragment.this.r();
                            return v1;
                        }
                        case 14: {
                            int v0_1 = !AppData.isNightMode() ? 1 : 0;
                            NewVideoDetailFragment.this.mAppData.aE();
                            CallbackCenter.notifyCallback(com.ss.android.j.b.callbackTypeNightModeChanged, new Object[0]);
                            NewVideoDetailFragment v2_1 = NewVideoDetailFragment.this;
                            String v0_2 = v0_1 != 0 ? "click_to_night" : "click_to_day";
                            v2_1.a(v0_2);
                            if (arg13 == null) {
                                return v1;
                            }

                            arg13.f();
                            arg13.e();
                            return v1;
                        }
                        case 15: {
                            NewVideoDetailFragment.this.a("display_setting");
                            return false;
                        }
                        case 16: {
                            NewVideoDetailFragment v0 = NewVideoDetailFragment.this;
                            if (v0.mArticle == null) {
                                return v1;
                            }
                            v0.a("report_button");
                            Article v2 = v0.mArticle;
                            if (v0.mDetailHelper == null) {
                                return v1;
                            }

                            v0.mDetailHelper.a(((AbsArticle) v2), v0.d);
                            return v1;
                        }
                    }

                    return false;


                }
            });
            this.mArticleShareHelper.mExtJsonObj = this.K();
            this.mArticleShareHelper.mCategoryName = this.R;
            this.mArticleShareHelper.detailSource = this.getEnterFrom();
        }
    }

    public final void p() {
        long v6 = 0;
        if (this.mVideoController != null) {
            if ((this.mVideoController.isFullScreen()) && (this.mVideoController.backPress(this.getActivity()))) {
                return;
            }

            if ((this.mVideoController.isDirectPlay()) && !this.mVideoController.isVideoPlaybackCompleted()) {
                this.mVideoController.pauseAtList();
            } else {
                this.a(4, this.mNewVideoFragmentHelper);
            }
        }
        if (this.mVideoAutoPlayHelperDetail != null) {
            this.mVideoAutoPlayHelperDetail.b(this.context);
        }

        if (this.c) {
            long v4 = this.H != v6 ? System.currentTimeMillis() - this.H : v6;
            MobClickCombiner.onEvent(this.context, "stay_category", "video_album", v4, v6);
        }

        if (this.isHostActivityDead()) {
            return;
        }

        ((NewDetailActivity) this.getActivity()).finishPage();

    }

    final boolean q() {
        boolean v0 = true;
        int v1 = this.getCommentMode();
        if (v1 != 1 && v1 != 2) {
            v0 = false;
        }

        return v0;
    }

    public final void r() {
        int v2;
        int v7 = com.ss.android.article.browser.R.drawable.doneicon_popup_textpage;
        Article v3 = this.mArticle;
        if (v3 != null) {
            long v4 = this.d;
            boolean v0 = !v3.userRepin ? true : false;
            v3.userRepin = v0;
            if (this.getCommentMode() == 0 && !this.isHostActivityDead()) {
                ((NewDetailActivity) this.getActivity()).setFavorIconSelected(v3.userRepin);
            }

            AppData.isNightMode();
            if (v3.userRepin) {
                this.showImageToast(v7, com.ss.android.article.browser.R.string.toast_favor);
                ++v3.repinCount;
                v2 = 4;
                ArticleHelper.a = true;
                this.a("favorite_success", ((BaseArticle) v3));
            } else {
                this.showImageToast(v7, com.ss.android.article.browser.R.string.toast_unfavor);
                --v3.repinCount;
                if (v3.repinCount < 0) {
                    v3.repinCount = 0;
                }

                ArticleHelper.a = false;
                v2 = 5;
            }

            this.mAppData.a = System.currentTimeMillis();
            List v6 = this.m.b();
            if (v3.userRepin) {
                if ((this.mAppData.mShareWhenFavor) && !v6.isEmpty()) {
                    this.mArticleActionHelper.a(v2, ((AbsArticle) v3), v4, v6);
                    return;
                }

                this.mArticleActionHelper.a(v2, ((AbsArticle) v3), v4);
                return;
            }

            this.mArticleActionHelper.a(v2, ((AbsArticle) v3), v4);
        }
    }

    public final String getEnterFrom() {
        String v0 = this.an;
        if (android.support.design.a.isTextEmpty(v0)) {
            if (this.Q != 1) {
                if (this.Q != 3 && !android.support.design.a.isTextEquals(v0, "click_search")) {
                    if (this.Q != 4 && !android.support.design.a.isTextEquals(v0, "click_pgc")) {
                        if (this.Q == 2) {
                            v0 = "favorite";
                        } else if (this.Q == 8) {
                            v0 = "read_history";
                        } else if (this.Q == 9) {
                            v0 = "push_history";
                        } else if (this.Q == 10) {
                            v0 = "refresh_history";
                        } else if (android.support.design.a.isTextEquals(v0, "click_subject")) {
                            v0 = "subject";
                        } else {
                            v0 = "";
                        }

                        return v0;
                    }

                    return "pgc_list";
                }

                v0 = "search";
            } else if ("__all__".equals(this.R)) {
                v0 = "headline";
            } else if (!android.support.design.a.isTextEmpty(this.R)) {
                v0 = this.R;
            }
        }

        return v0;
    }

    final void startPlayVideo() {
        IVideoController videoController = this.getVideoController();
        if (videoController != null) {
            Article article = this.mArticle;
            if (article == null) {
                return;
            }
            JSONObject jsonObject = new JSONObject();
            try {
                jsonObject.put("log_pb", this.mLogPb);
                jsonObject.put("search_result_id", this.mSearchResultId);
                jsonObject.put("query", this.mQuery);
                jsonObject.put("source", this.mSource);
            } catch (JSONException jsonException) {
            }

            String v3_1 = null;
            String v4 = this.R;
            String title = article.title;
            long v6 = this.d;
            String v9 = this.aF;
            int v11 = this.aG;
            int v12 = this.aH;
            List v13 = article.adVideoClickTrackUrls;
            long v14 = this.bi;
            String v16 = this.an != null ? this.an : this.J();
            videoController.play(v3_1, v4,
                    title, v6, article,
                    v9, 0, v11, v12,
                    v13, v14,
                    v16, this.bj, this.P,
                    this.bundleDownloadAppLogExtra, jsonObject);
            this.bj = false;
            if (this.bi > 0) {
                this.bi = -1;
            }

            if (this.mThirdVideoPartnerData == null) {
                return;
            }

            if (TextUtils.isEmpty(this.mThirdVideoPartnerData.androidOpenUrl)) {
                return;
            }

            if (TextUtils.isEmpty(this.mThirdVideoPartnerData.androidDownloadUrl)) {
                return;
            }

            if (TextUtils.isEmpty(this.mThirdVideoPartnerData.packageName)) {
                return;
            }

            if (this.getVideoController() == null) {
                return;
            }
            this.getVideoController().showThirdPartnerGuide(this.mThirdVideoPartnerData, this.mThirdPartnerListner);
        }
    }

    public final void u() {
        if (this.mNewVideoFragmentHelper != null) {
            Article article = this.mArticle;
            if (article != null && (article.delete) && !this.isHostActivityDead()) {
                ((NewDetailActivity) this.getActivity()).switchToArticleDeleted(article);
                return;
            }

            NewVideoFragmentHelper newVideoFragmentHelper = this.mNewVideoFragmentHelper;
            newVideoFragmentHelper.o = false;
            newVideoFragmentHelper.n = false;
            newVideoFragmentHelper.p = false;
            newVideoFragmentHelper.m = false;
            newVideoFragmentHelper.l = false;
            newVideoFragmentHelper.mNewDetailAdapter.addAllComment((List) null);
            newVideoFragmentHelper.mNewDetailAdapter.notifyDataSetChanged();
            long v2 = this.f;
            if (article != null) {
                v2 = article.groupId;
            }

            if (v2 > 0) {
                newVideoFragmentHelper.mNewDetailAdapter.e = String.valueOf(v2);
            }

            if (article != null && article.groupId == this.aq && this.aq > 0 && !this.as) {
                this.as = true;
                newVideoFragmentHelper.l = true;
            }

            String v2_5;
            Article v3_2;
            if (newVideoFragmentHelper != null) {
                long v6 = this.mArticle.itemId;
                int v8 = this.mArticle.aggrType;
                long v4_1 = this.mArticle.groupId;
                long v12 = this.d;
                newVideoFragmentHelper.mContentLayout.setVisibility(View.GONE);
                newVideoFragmentHelper.mDetailErrorView.showLoadingView();
                if (this.mArticleDetail == null) {
                    this.aX.loadArticleDetailByLocal(this.mArticle.getItemKey(), this.mArticle, this.mArticle);
                } else {
                    this.onArticleDetailLoadedFromInternet(this.mArticleDetail);
                }

                Object v2_3;
                if (newVideoFragmentHelper.m) {
                    long v14 = System.currentTimeMillis();
                    if (this.mArticle != null && v14 - this.mArticle.clickTimestamp < 60000) {
                        Article v11 = this.mArticle;
                        if (v11 != null) {
                            v11.clickTimestamp = System.currentTimeMillis();
                            DBHelper v2_1 = DBHelper.getInstance(this.context);
                            if (v2_1 != null) {
                                v2_1.syncReadTs(v11);
                                if (ArticleHelper.b >= 0 && v11 != null && this.mAppData != null) {
                                    FeedTab v2_2 = this.mAppData.t();
                                    if (v2_2 != null) {
                                        ArrayList v3 = new ArrayList();
                                        v2_2.getCurrentList(-1, ((List) v3));
                                        if (((List) v3).size() > ArticleHelper.b) {
                                            v2_3 = ((List) v3).get(ArticleHelper.b);
                                            if (v2_3 != null && ((CellRef) v2_3).ac != null && ((CellRef) v2_3).ac.size() != 0) {
                                                int v9 = 0;
                                                while (v9 < ((CellRef) v2_3).ac.size()) {
                                                    Object v3_1 = ((CellRef) v2_3).ac.get(v9);
                                                    if (((CellRef) v3_1).article.groupId == v11.groupId) {
                                                        ((CellRef) v3_1).article.clickTimestamp = System.currentTimeMillis();
                                                        ArticleHelper.a(this.getContext(), ((CellRef) v2_3), v9);
                                                    } else {
                                                        ++v9;
                                                        continue;
                                                    }

                                                    break;
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }

                    if (this.F > 0) {
                    } else {
                        this.F = v14;
                        this.b = new BaseArticle(v4_1, v6, v8);
                        this.G = v12;
                    }
                }

                com.ss.android.article.base.feature.detail2.video.a.l v2_4 = newVideoFragmentHelper.e;
                v3_2 = this.mArticle;
                v2_4.I = v3_2;
                if (v2_4.H == null || v3_2 == null || v2_4.H.itemId != v3_2.groupId) {
                    v2_4.p.setVisibility(View.GONE);
                    v2_4.D.setVisibility(View.GONE);
                }

                article = this.mArticle;
                if (article != null) {
                    v2_3 = this.aV.get(Long.valueOf(article.groupId));
                    v6 = System.currentTimeMillis();
                    int v3_3 = v2_3 == null || v6 - ((ArticleInfo) v2_3).d > 600000 ? 1 : 0;
                    if (v3_3 != 0 && (NetworkUtils.isNetworkAvailable(this.context))) {
                        DetailLoader v3_4 = this.aX;
                        String v5 = article.getItemKey();
                        v2_5 = this.au ? "apn" : this.an;
                        v3_4.loadArticleInfo(v5, article, v2_5);
                    } else {
                        this.onArticleInfoLoaded(article, ((ArticleInfo) v2_3));
                    }
                }

                Article v5_1 = this.mArticle;
                if (v5_1 == null) {
                } else if (this.q()) {
                } else {
                    CommentTabCache v11_1 = this.a(v5_1.groupId, newVideoFragmentHelper);
                    int v2_6 = System.currentTimeMillis() - v11_1.mArticleTabComments[0].h > 600000 ? 1 : 0;
                    if (v2_6 == 0) {
                    } else {
                        long v8_1 = 0;
                        if (v5_1.groupId > 0 && v5_1.groupId == this.aq && !this.at) {
                            v8_1 = this.ar;
                            this.at = true;
                        }
                        CommentFetcher v3_5 = new CommentFetcher(v11_1.mArticleTabComments[0].increateCounter(), ((AbsArticle) v5_1), 0, 0, v8_1);
                        this.aX.loadComment(v3_5.getItemKey(), v3_5);
                        v11_1.load[0] = true;
                        this.a(v8_1);
                        if (newVideoFragmentHelper == null) {
                        } else if (!NetworkUtils.isNetworkAvailable(this.context)) {
                        } else if (newVideoFragmentHelper.mNewDetailAdapter.getCount() != 0) {
                        } else {
                            newVideoFragmentHelper.mFooter.switchToLoading();
                        }
                    }
                }
            }

            if (this.mVideoController != null && !this.mVideoController.isFullScreen() && this.mArticle != null && this.mNewVideoFragmentHelper != null) {
                switch (this.getCommentMode()) {
                    case 1:
                    case 2: {
                        if (!this.isHostActivityDead()) {
                            ((NewDetailActivity) this.getActivity()).setDetailToolBarVisible(false);
                        }

                        this.mNewVideoFragmentHelper.mFooter.hideFooterContent();
                        this.mNewVideoFragmentHelper.e.a(8);
                        this.mNewVideoFragmentHelper.mNewDetailAdapter.addAllComment((List) null);
                        this.mNewVideoFragmentHelper.mNewDetailAdapter.notifyDataSetChanged();
                        break;
                    }
                    default: {
                        if (!this.isHostActivityDead()) {
                            ((NewDetailActivity) this.getActivity()).setDetailToolBarVisible(true);
                            this.m();
                        }

                        this.mNewVideoFragmentHelper.e.a(0);
                        if (this.mNewVideoFragmentHelper.mCommentTabCache == null) {
                            break;
                        }
                        this.a(this.mNewVideoFragmentHelper, this.mNewVideoFragmentHelper.mCommentTabCache);
                        break;
                    }
                }

                v3_2 = this.mArticle;
                if (this.bf) {
                } else {
                    this.bf = true;
                    v2_5 = "";
                    switch (v3_2.getCommentMode()) {
                        case 1: {
                            v2_5 = "no_comments_mode";
                            break;
                        }
                        case 2: {
                            v2_5 = "hide_mode";
                            break;
                        }
                    }
                    if (android.support.design.a.isTextEmpty(v2_5)) {
                    } else {
                        this.a(v2_5, v3_2);
                    }
                }
            }

            this.a(newVideoFragmentHelper, AppData.isNightMode());
            this.I();
        }
    }

    final void v() {
        long v6 = 0;
        if (mNewVideoFragmentHelper != null) {
            Article v3 = this.mArticle;
            if (v3 == null) {
                mNewVideoFragmentHelper.mFooter.hideFooterContent();
            } else {
                boolean v1 = mNewVideoFragmentHelper.l;
                mNewVideoFragmentHelper.l = true;
                CommentTabCache v8 = this.a(v3.groupId, mNewVideoFragmentHelper);
                if (!v8.load[0]) {
                    ArticleTabComment v2 = v8.mArticleTabComments[0];
                    if (!v2.hasComment) {
                        if (NetworkUtils.isNetworkAvailable(this.context)) {
                            CommentFetcher v1_1 =
                                    new CommentFetcher(v8.mArticleTabComments[0].increateCounter(),
                                            ((AbsArticle) v3), 0, 0, v6);
                            this.aX.loadComment(v1_1.getItemKey(), v1_1);
                            v8.load[0] = true;
                            mNewVideoFragmentHelper.mFooter.switchToLoading();
                            this.a(v6);
                        } else {
                            this.M();
                        }
                    } else if (v3.groupId != v8.itemId) {
                        mNewVideoFragmentHelper.mFooter.hideFooterContent();
                    } else {
                        if (!v1 && (mNewVideoFragmentHelper.mNewDetailAdapter.hasComments())) {
                            this.a(mNewVideoFragmentHelper, v8);
                            if (!mNewVideoFragmentHelper.o) {
                                mNewVideoFragmentHelper.o = true;
                                this.a("enter_comment", ((BaseArticle) v3), this.d);
                            } else {
                            }

                            return;
                        }

                        if (v2.isEmpty()) {
                            mNewVideoFragmentHelper.mFooter.hideFooterContent();
                            return;
                        }

                        if (v8.load[0]) {
                            mNewVideoFragmentHelper.mFooter.switchToLoading();
                            return;
                        }

                        if (!NetworkUtils.isNetworkAvailable(this.context)) {
                            this.M();
                            return;
                        }

                        MobClickCombiner.onEvent(this.getContext(), "detail", "comment_loadmore");
                        v8.load[0] = true;
                        mNewVideoFragmentHelper.mFooter.switchToLoading();
                        new ArticleTabCommentsRequestTask(this.context,
                                this.ax, new CommentFetcher(v2.increateCounter(),
                                ((AbsArticle) v3), 0, v2.offset, v6)).start();
                        if (mNewVideoFragmentHelper.p) {
                            return;
                        }

                        mNewVideoFragmentHelper.p = true;
                        this.a("finish_comment", ((BaseArticle) v3), this.d);
                    }
                }
            }
        }
    }

    private boolean w() {
        long v8 = 0;
        boolean v2 = false;
        Bundle v3 = this.getArguments();
        if (v3 != null) {
            this.d(((NewDetailActivity) this.getActivity()).getArticle2());
            this.mVideoAutoPlayHelperDetail.a(this.mArticle, this.ba);
            this.mVideoAutoPlayHelperDetail.a(false);
            if (this.mArticle == null) {
                return v2;
            }

            this.mArticleDetail = ((NewDetailActivity) this.getActivity()).getArticleDetail();
            this.au = v3.getBoolean("from_notification", false);
            this.ap = v3.getString("gd_ext_json");
            this.R = v3.getString("category");
            v3.getString("enter_from");
            boolean v4 = v3.getBoolean("view_comments", false);
            this.al = v3.getBoolean("is_jump_comment", false);
            boolean v0 = !this.al ? true : false;
            this.z = v0;
            this.am = v3.getBoolean("show_write_comment_dialog", false);
            this.bb = v3.getString("growth_from");
            if (v3.containsKey("detail_source")) {
                this.an = v3.getString("detail_source");
            } else if (this.au) {
                this.an = "click_apn";
            }

            String v0_1 = this.an != null ? this.an : this.getEnterFrom();
            this.ag = v0_1;
            if (v3.containsKey("stay_tt")) {
                this.ao = v3.getInt("stay_tt");
                if (this.ao == 0) {
                    v3.getInt("previous_task_id");
                    v3.getString("previous_task_intent");
                }
            }

            v3.getBoolean("is_ugc_style");
            this.L = v3.getBoolean("view_single_id", false);
            this.f = this.mArticle.groupId;
            this.M = this.mArticle.itemId;
            this.N = this.mArticle.aggrType;
            this.d = v3.getLong("ad_id", v8);
            this.bundleDownloadAppLogExtra = v3.getString("bundle_download_app_extra");
            v0_1 = v3.getString("log_pb", "");
            try {
                if (!android.support.design.a.isTextEmpty(v0_1)) {
                    this.mLogPb = new JSONObject(v0_1);
//                    goto label_96;
                } else if (android.support.design.a.isTextEmpty(this.ap)) {
//                    goto label_96;
                } else {
                    this.mLogPb = new JSONObject(this.ap).optJSONObject("log_pb");
                }
            } catch (JSONException v0_2) {
            }

            label_96:
            if (!android.support.design.a.isTextEmpty(this.ap)) {
                try {
                    JSONObject v0_3 = new JSONObject(this.ap);
                    this.mSource = v0_3.optString("source");
                    this.mQuery = v0_3.optString("query");
                    this.mSearchResultId = v0_3.optLong("search_result_id");
                } catch (JSONException v0_2) {
                }
            }

            if (this.L) {
                this.O = v3.getLong("from_gid", v8);
            } else {
                this.Q = v3.getInt("list_type", 0);
                if (this.mNewVideoFragmentHelper != null && this.mNewVideoFragmentHelper.mNewDetailAdapter != null) {
                    this.mNewVideoFragmentHelper.mNewDetailAdapter.mAdId = this.d;
                }

                if (!v4) {
//                    goto label_116;
                } else {
                    if (this.mArticle == null) {
//                    goto label_116;
                    } else {
                        this.aq = this.mArticle.groupId;
                        if (this.mArticle.comment == null) {
//                    goto label_116;
                        } else {
                            this.ar = this.mArticle.comment.commentId;
                        }
                    }
                }
            }

            label_116:
            v0 = (this.al) || this.Q <= 0 ? true : false;
            this.ak = v0;
            this.bi = v3.getLong("video_play_position");
            this.bj = v3.getBoolean("video_direct_play_in_feed", false);
            this.B = this.al;
            v2 = true;
        }

        return v2;
    }

    private void x() {
        JSONObject v6;
        JSONObject v0 = null;
        long v8 = 0;
        if (this.b != null && this.b.groupId > v8 && this.F > v8) {
            long v4 = System.currentTimeMillis() - this.F;
            if (v4 <= 3000) {
                return;
            }

            if (this.G > v8) {
                try {
                    v6 = new JSONObject("{\"ad_id\":" + this.G + "}");
                } catch (Exception v1) {
                    v6 = v0;
                }
            } else {
                v6 = v0;
            }

            if (!this.mVideoAutoPlayHelperDetail.a(this.context, this.J(), this.b, v4, v6)) {
                if (AppData.getInstance().getAbSettings().isAppLogOld()) {
                    this.a("stay_page", this.b, v4, v6);
                }

                if (AppData.getInstance().getAbSettings().isAppLogNew()) {
                    if (v6 == null) {
                        v0 = new JSONObject();
                    } else {
                        v0 = v6;
                    }

                    try {
                        v0.put("stay_time", v4);
                    } catch (Exception v1) {
                    }

                    label_49:
                    this.a("stay_page", v0, this.b);
                }

                if (this.G <= v8) {
                    return;
                }

                this.a("stay_page2", this.b, this.G);
            }
        }
    }

    public final void onBackClick() {
        this.onBack();
    }

    public final void onTopMoreTitleClick() {
    }

    final static class a$a extends AbstractFooter {
        private final NewVideoDetailFragment j;

        public a$a(NewVideoDetailFragment arg1, View arg2) {
            super(arg2);
            this.j = arg1;
        }

        public final void onUserClick() {
            if (this.j.mNewVideoFragmentHelper != null) {
                this.j.a(this.j.f, this.j.mNewVideoFragmentHelper);
                this.j.v();
            }
        }

        public final void switchToLoading() {
            super.switchToLoading();
            NewVideoDetailFragment v0 = this.j;
            if (v0.mNoNetView != null) {
                v0.mNoNetView.setVisibility(View.GONE);
            }
        }
    }

    final class a$b implements IShareListener {
        private WeakReference a;

        public a$b(NewVideoDetailFragment arg2) {
            this.a = new WeakReference(arg2);
        }

        public final void onFullScreenMoreClick() {
            Object v0 = null;
            if (this.a != null) {
                v0 = this.a.get();
            }

            if (v0 != null) {
                JSONObject v1 = new JSONObject();
                try {
                    v1.put("source_type", "video");
                    v1.put("section", "player_more");
                    v1.put("fullscreen", "fullscreen");
                    v1.put("icon_seat", "inside");
                } catch (JSONException v2) {
                }

                ((NewVideoDetailFragment) v0).d("detail", v1);
                ((NewVideoDetailFragment) v0).d(true);
            }
        }

        public final void onTopMoreClick() {
            Object v0 = null;
            if (this.a != null) {
                v0 = this.a.get();
            }

            if (v0 != null) {
                JSONObject v1 = new JSONObject();
                try {
                    v1.put("source_type", "video");
                    v1.put("section", "player_more");
                    v1.put("fullscreen", "notfullscreen");
                    v1.put("icon_seat", "inside");
                } catch (JSONException v2) {
                }

                ((NewVideoDetailFragment) v0).d("detail", v1);
                ((NewVideoDetailFragment) v0).d(true);
            }
        }
    }
}

